need to run javascripts on iframe which loads an e

2019-02-20 07:42发布

mysite.com has an iframe which loads some differentsite.com.

need to run javascript on this loaded iframe document.

Single Origin Policy kicks in.

i resort to using proxy. its slow, creates bottleneck, unable to fully render the site (JS is not rendered).

Alternatives ?

3条回答
Deceive 欺骗
2楼-- · 2019-02-20 07:58

Check this blog post of .Net Slave, I think it might solve your issue Iframe cross domain JavaScript calls

查看更多
Fickle 薄情
3楼-- · 2019-02-20 07:59

You could try window.postMessage(message, origin) (it would be parent.postMessage from the iframe and iframeElement.contentWindow.postMessage from the top page) for all of the latest major browsers (Firefox, IE, Safari, Chrome, etc.) and changing/polling window.name for old browsers.

查看更多
Anthone
4楼-- · 2019-02-20 08:16

The first question would be, do you have control over the secondary domains, or are you able to persuade the webmasters of these to add additional components?

If so you could easily use easyXDM to call methods across the domain boundry. Demos of this can be viewed here

查看更多
登录 后发表回答