将表单发布到iframe并使用javascript从iframe中获取内容?

时间:2012-12-04 06:33:45

标签: javascript iframe cross-domain

我正在一个网站上工作,我需要从iframe获取内容。 代码在这里。

<!DOCTYPE html>
<html>
<head>
    <script src="http://code.jquery.com/jquery-lates…
</head>
<body>
    <iframe src="http://glimmertech.org/IF222.htm" width="80%" height="600" id="frameDemo">       </iframe>

    <script>
    var myFrame = $('#frameDemo');

    myFrame.load(function()
    {
       var myjQueryObject = $('#frameDemo').contents().find('#newid'…
       alert(myjQueryObject[0].innerHTML);
    });
    </script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

试试这个:

 var myIframe = document.getElementById('frameDemo');
 var myObject = myIframe.contentWindow.document.getElementById('newid');
 alert(myObject.innerHTML);
相关问题