javascriptgoogle-chromeiframeonbeforeunloadwindow.onunload

Parent iframe won't reload when popup closes


I have a function in parent iframe.

var reloadFrameWindow = function() {
    "use strict";
    var doc, myFrame, keyElem, url;
    doc = document;
    myFrame = doc.getElementById("myFrame");
    keyElem = doc.getElementById("key"); 
    if (myFrame && keyElem) {
        keyElem.value = keyElem.value + "X";
        url = myFrame.src;
        url = updateQueryStringParameter(url, "key", keyElem.value);
        jQuery.ajax({
            type: "GET",
            url: url,
            success: function() {
                myFrame.src = newUrl;
            }
        });
    }
 };

In my pop up I have added

window.onbeforeunload = function() {
    "use strict";
    window.opener.reloadFrameWindow();
};
  1. If I close it on IE11, 8 the parent iframe gets reloaded.
  2. If I close it on chrome, it doesn't reload parent iframe but the key element value does increase by 1 in both cases.

Note: I want this to fire only when it closes, not when the back button is clicked. But I wouldn't mind if it happens in both cases


Solution

  • actually i found that doing this in chrome works..

    jQuery.ajax({
                    type: 'GET',
                    url: newUrl,
                    success: function() {
                        myFrame.src = newUrl;
                    }
                });