Are there any events that I can listen to on an iframe on a different domain? For example, have this page on domain1:
<html>
<body>
<iframe src="domain2.com"></iframe>
</body>
</html>
What events can I listen to with regard to the contentWindow of the iframe?
Thanks!
There are a couple of ways to do this. In newer browsers, you can use window.postMessage to communicate across domains between windows (works for iframes too):
https://developer.mozilla.org/en/DOM/window.postMessage
For older browsers, you can change the URL fragment for the location of the iframe to pass messages back and forth. You can use a separate iframe just to pass messages to avoid polling: http://ajaxian.com/archives/cross-domain-iframe-communication-without-location-polling
我不知道这应该是一个问题(在IE中有另一个域的iframe)也许你的问题是你是直接从你的计算机打开文件...一旦这些文件被托管,你不应该看到这个问题发生。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.