开发者

java script - DOM permission

开发者 https://www.devze.com 2023-02-03 08:42 出处:网络
How can I call a function in the parent, from iframe (child); when i do it in following way, browser says

How can I call a function in the parent, from iframe (child); when i do it in following way, browser says

"Permission denied for <http://localhost> 
to get property Window.func from <http://localhost:8080>.
    [Break On This Error] parent.window.func(); "

call in iframe

parent.window.func()

the function in the parent

function func(){
        alert("test开发者_开发知识库")
};


For security reasons, you cannot interact with a frame containing a webpage in a different domain or port.


For some reason, you are doing a cross-domain request, which breaks the same origin policy. You can only access other windows if they are from the same domain as the window in question.

http://localhost is a different domain to http://localhost:8080; the different ports make the request forbidden.

0

精彩评论

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