i have a page that contain iframe.
when user click on the edit icon open new windows for edit this image
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.
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).