开发者

Refreshing nested iframe from separate window

I have an iframe called "mainframe" you click a link inside the iframe, and it uses javascript to open a small popup window. I have a form inside this popup-window that submits data to be displayed in the iframe. (its a comment feature) I w开发者_开发问答ant there to be a way that when the user clicks "submit" the popup window closes, and the iframe refreshes. How to do this?


From within the popup window, you can use the opener property to get to the parent window. From there, you can use the frames collection to get to your iframe...

window.onload = function() {
  document.getElementById('btnSubmit').onclick = function() {
    opener.frames[0].location.reload(true);
    self.close();
  }
}

Alternatively, if you need some kind of delay, you can setup a function in the parent window...

function refreshIframe() {
  setTimeout(function() {
    frames[0].location.reload(true);
  }, 1000);
}

And invoke it from the popup...

opener.refreshIframe();
self.close();


This might seem as a stupid answer but lets throw a dart with closed eyes. So to the point u can definitely do this with help of jquery in case of div not sure about frame but should work according to me


Try the following to refresh your iframe: document.getElementById("mainframe").contentDocument.location.reload(true);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜