开发者

iFrame access denied remote domain

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜