0

这是场景,我们的页面中有 iframe 的应用程序。

我有 2 页,其中有一个简单的表格:

    <form method="get" action="iframed.html">
    Zip Code:
    <input id="txtZipCode" type="text" name="ZipCode" />
    <input id="btnSubmit" type="submit" value="Submit" />
    </form>

另一个将信息提取到页面内的 iframe 表单中。

    <iframe src="blahblahForm.html" ></iframe>

如何提取在第一页输入的邮政编码,并用 iframed 表单填写到页面中?

谢谢

4

1 回答 1

0

假设 iframe src 在同一个域中,您可以这样做:

function setZipInIframe(zip){
   //load the input iframe and set a value
   getIframeDocument().getElementById('txtZipCode').value = zip;
}    


function getIframeDocument(){
            var iframe = document.getElementById("ifrId"); 
            //contentDocument because IE8 doesn't support contentWindow
            return (iframe.contentDocument || iframe.contentWindow.document);   
        }
于 2013-06-06T22:05:07.207 回答