need to run javascripts on iframe which loads an external domain

后端 未结 2 510
南旧
南旧 2021-01-16 02:22

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

need to run javascript on this loaded iframe document.

Single Or

2条回答
  •  野的像风
    2021-01-16 02:41

    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.

提交回复
热议问题