简体   繁体   English

无法在IE8-11中的其他域中使用jQuery访问iframe

[英]Can't access iframe using jQuery in another domain In IE8-11

I can't access iframe using jQuery in localhost or if i use another domain In IE8-11 . 我无法在localhost中使用jQuery或在IE8-11中使用其他域来访问iframe
i use Smart Demo-bar script it work perfectly on other browsers but in IE8-11 it must be in some domain or all function provide py Demo-bar break. 我使用Smart Demo-bar脚本,它可以在其他浏览器上完美运行,但在IE8-11中,它必须在某些域中,或者所有功能都可以提供py Demo-bar break。

- i have try add an onload event to the iframe. -我尝试向iframe添加onload事件。 (But this will only work if the source in the iframe is from the same domain.) (但这仅在iframe中的源来自同一域时才有效。)
- Another solution i fond in stackoverflow convert jQuery to JS . -我喜欢stackoverflow的另一个解决方案将jQuery转换为JS。

Please if there's way to fix this issues on IE i'll be Thankful. 如果有办法在IE上解决此问题,请多谢。

Internet Explorer has a very restrictive set of rules regarding Cross-domain access (as you have just noticed). Internet Explorer对于跨域访问有一组非常严格的规则(正如您刚刚注意到的)。 The sandboxing between the "host" page and the iframe is meant to prevent XSS attacks. “主机”页面和iframe之间的沙箱旨在防止XSS攻击。

If you are trying to make an ajax call, jQuery provides the JSONP (JSON with padding) data type, just to circumvent Cross-domain restrictions 如果您尝试进行ajax调用,则jQuery提供JSONP(带填充的JSON)数据类型,只是为了规避跨域限制

If you want to pass event or function calls, you will need a third-party plugin, here is a sample: http://calibrate.be/labs/cross-domain-iframe-communication 如果要传递事件或函数调用,则需要一个第三方插件,这里是一个示例: http : //calibrate.be/labs/cross-domain-iframe-communication

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM