Roload Iframe

来源:互联网 发布:电影票用什么软件 编辑:程序博客网 时间:2024/06/07 04:46
<div class="project">  <iframe id="currentElement" class="myframe" name="myframe" src="http://somesite.com/something/new"></iframe></div>

像上边的一个iframe,要重新加载,分两种情况:
1. 同一个域名

document.getElementById(FrameID).contentDocument.location.reload(true);

或者

iframe.contentDocument.location=iframe.src

IE9下面用这个:

document.getElementById(FrameID).contentWindow.location.reload(true);
  1. 不同域名
    如果是不同域名的话,contentDocument 会被禁止。具体请看下面的链接:
    https://en.wikipedia.org/wiki/Same-origin_policy

用下面的方式可以实现:

var iframe = document.getElementById(FrameId);iframe.src = iframe.src;

如果你想从一个iframe里重新加载另一个iframe,很不幸, that is not possible。

http://stackoverflow.com/questions/4249809/reload-an-iframe-with-jquery

0 0