开发者

iFrame access denied remote domain

开发者 https://www.devze.com 2022-12-17 12:29 出处:网络
How do i send a JavaScript function to an iframe with external content loaded, eg onclick=\"getElementByID(\'myifra开发者_开发问答me\').src=\'fun();\'\"

How do i send a JavaScript function to an iframe with external content loaded,

eg

onclick="getElementByID('myifra开发者_开发问答me').src='fun();'"

is there a way with ajax, i think XMLHttpRequest can help me.


You can't, it's a security feature


everything must be on the same domain. or you will need to setup a proxy


As stated earlier you cannot do this because of the builtin security model of the browsers.

However, if the two sites are hosted on the same subdomain, for example appA.company.com and appB.company.com, you can get around it using domain relaxation. All you have to do is to set the document.domain in both pages to company.com. See http://www.tomhoppe.com/index.php/2008/03/cross-sub-domain-javascript-ajax-iframe-etc/ for more information

0

精彩评论

暂无评论...
验证码 换一张
取 消