通过其他页面重新加载帧

通过其他页面重新加载帧

问题描述:

i have a page that contain iframe. enter image description here

when user click on the edit icon open new windows for edit this image enter image description here

enter image description here

when finished edit image click on the save.

now how can refresh ifram(first image) to update images that edited?

there is way in jquery or php for do it? or me should use web socket?

i can refresh pages that call editor with this code but i want reload frame only.

    <script language="javascript" type="text/javascript"> 
      window.open(\'\',\'_parent\',\'\');window.close();
   </script>

Sorry me for bad english.

我有一个包含iframe的页面。 p>

当用户点击编辑图标时,打开新窗口以编辑此图像 p>

p>

完成编辑图像后点击保存。 p>

现在如何刷新ifram (第一张图片)更新编辑过的图片? p>

在jquery或php中有办法吗?我也不应该使用网络套接字? p>

我可以使用此代码刷新调用编辑器的页面,但我只想重新加载帧。 p>

 &lt; script language =“javascript”type =“text / javascript”&gt;  
 window.open(\'\',\'_ parent \',\'\'); window.close(); 
&lt; / script&gt; 
  code>  pre> 
 
  

抱歉我的英文不好。 p> div>

Since it is a new window you first need to reach the opener which is window.opener. Give your iframe an id, and you can reach it by using: document.getElementById. Putting it together, it would be something like this:

 window.opener.document.getElementById('youriframe').location.reload( true );

You might also call a method in the opener context:

// in window opener:
function refreshFrame() {
  document.getElementById('IdOfYourFrame').location.reload(true);
}

// in new window (window open) you call the method by:
window.opener.refreshFrame();

I put together a Codepen Expamle to demonstrate. Be aware that this is only working in case the different window locations are from the same domain (window.opener cross-domain security).