我正在尝试使用 js 或 jQuery 从 iframe 外部获取元素。我发现了一些东西,但它不是跨浏览器的。
<div id=vi-desc-maincntr"">
<div class="u-flL iti-act-num">123456789</div>
<div id="desc_div">
<iframe src="LOCATION">
</div>
</div>
我需要将该数字放入变量中。
同源策略:
您可能想检查一下。两个页面需要具有相同的来源。
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
If your child page is located at same domain as parent page, You can write a code like below in the child window :
$('#test1', parent.document).html('<h1>clicked</h1>');
第二个参数提供context
在其中搜索与第一个参数匹配的元素。该文档在这里:http://api.jquery.com/jQuery/#jQuery-selector-context http://api.jquery.com/jQuery/#jQuery-selector-context
jQuery( selector [, context ] )
希望这可以帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)