当前位置: 代码迷 >> JavaScript >> 用document.frames['myframe'].location.reload(true)刷新iframe时提示"权限不够",怎么解决
  详细解决方案

用document.frames['myframe'].location.reload(true)刷新iframe时提示"权限不够",怎么解决

热度:519   发布时间:2012-02-24 16:30:38.0
用document.frames['myframe'].location.reload(true)刷新iframe时提示"权限不够",如何解决?
代码如下,当iframe引用的是别的站点的页面时,就会提示权限不够,同一个站点时就没问题,请问该如何解决?
<body   onload= "javascript:document.frames[ 'myframe '].location.reload(true) ">
<iframe   id= "myframe "   src= "http://www.mytest.com/top.html "> </iframe>
</body>

------解决方案--------------------
跨域的问题,没得解.
------解决方案--------------------
换个方案:
try:document.all.myframe.src= document.all.myframe.src
------解决方案--------------------
<body onload= "javascript:window.document.frames[ 'myframe '].location=window.document.frames[ 'myframe '].location ">
<iframe id= "myframe " src= "http://www.mytest.com/top.html "> </iframe>
</body>
------解决方案--------------------
<body onload= "javascript:window.document.frames[ 'myframe '].location.href=window.document.frames[ 'myframe '].location.href; ">
<iframe id= "myframe " src= "http://www.mytest.com/top.html "> </iframe>
</body>
------解决方案--------------------
跨域的话不能访问iframe内页的对象,会提示权限不足
------解决方案--------------------
document.frames[ 'myframe '].location

location不是iframe标签内的属性,是内部的对象

在iframe里面提交iframe的地址到parent的var中,用iframe.src=var
这样应该差不多吧

------解决方案--------------------
Tianminghui(colin)说的没错! location 也是内部的对象!跨域的情况下是无权访问的!但是,FEB15(张郎)的方法也可以起到刷新的效果的~~
  相关解决方案