admin管理员组文章数量:1332404
everyone. I created my page and inserted inside another page using IFrame. Now I'm trying to get whole text of that inserted page using pure javascript or jquery. Here's what I have now, but it doesn't work...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.5.1.js"></script>
<script type="text/javascript">
function getFrameContents(){
return $("#myframe").contents().find('body');
}
</script>
</head>
<form>
<input type="button" value="CodingForums" onClick="window.alert(getFrameContents())" />
</form>
<iframe id='myframe' src="/" width="100%" height="300">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
I've read also that there is some policy about accessing pages from different server. How can I do it properly?
everyone. I created my page and inserted inside another page using IFrame. Now I'm trying to get whole text of that inserted page using pure javascript or jquery. Here's what I have now, but it doesn't work...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.5.1.js"></script>
<script type="text/javascript">
function getFrameContents(){
return $("#myframe").contents().find('body');
}
</script>
</head>
<form>
<input type="button" value="CodingForums" onClick="window.alert(getFrameContents())" />
</form>
<iframe id='myframe' src="http://www.fxstreet./rates-charts/currency-rates/" width="100%" height="300">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
I've read also that there is some policy about accessing pages from different server. How can I do it properly?
Share Improve this question asked Mar 8, 2011 at 12:41 Konstantin MilyutinKonstantin Milyutin 12.4k12 gold badges61 silver badges86 bronze badges2 Answers
Reset to default 4I've read also that there is some policy about accessing pages from different server.
Yes there is and the policy says it's strictly forbidden.
How can I do it properly?
Fetch it on the server-side. You might want to use a server-side cache too.
Many people ask this question...
The best way people describe is (as i dont like iframes) but you need on iframe to collect the data and use window.top....
to access the main page and pass it that way because .contents()
is not supported by all browsers.
本文标签: javascriptGet content of iframe from jqueryStack Overflow
版权声明:本文标题:javascript - Get content of iframe from jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742271813a2444446.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论