Javascript 被拒绝访问 IFRAME 中的属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6690598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Permission denied to access property in IFRAME
提问by Saurabh Kumar
I have a link in my jsp page .
我的 jsp 页面中有一个链接。
the link looks like this
链接看起来像这样
<a href="javascript:doSomething('abc.ff' , 'abc.ff?m=1')">
the javascript code
javascript代码
function doSomething(url, url_progress){
parent.win1.location.href = url;
/* Wait until something surely has started! */
window.setTimeout("this.startFinally()", 1000);
this.startFinally = function (){
location.href = url_progress;
}
}
When the user clinks on this clinks everything works fine. Now recently I put this code inside a Iframe and then nothing happens. I checked with firebug and got this error :
当用户在这个叮当声上碰杯时,一切正常。现在最近我把这段代码放在一个 Iframe 中,然后什么也没发生。我检查了萤火虫并收到此错误:
Permission denied to access property 'win1'
[Break On This Error] parent.win1.location.href = url;
What can be the problem?
可能是什么问题?
回答by Waldheinz
It's possibly the same origin policykicking in. Is everything served from the same host/port?
可能是同源策略开始生效。所有内容都来自同一个主机/端口吗?