Monday, February 21, 2011

How to handle parents browser windows page features from child windows close in JS

I open a page in browser. There is a link where I click, its fade the page, by putting a layer in the Z-index. At the mean time another Pop up window is also open. When I close the pop up window, the browser remain still faded. I can’t disable the z-index layer that I put in the parents window. Enter code is done in Java Script.

From stackoverflow
  • I believe want you want to do is something like this. On your parent window/page:

    var fadeIn = function fadeIn() {
        // Code to remove added layer
    };
    

    And on your child/popup window/page:

    window.onunload = function () {
        window.opener.fadeIn();
    }
    
  • Any JavaScript that resides in the parent page can be called by the child. In your child popup your "close' button click event should have an event similar to this:

    function closePopup()
    { 
        parent.FadeOut();  // Where fadeOut() is a JS function on the parent page
    }
    
    
    //In the Parent Page
    function fadeOut()
    {
       document.getElementById('myLayer').zindex = 0; //Or similar 
    }
    
    PortageMonkey : Was this what you were looking for in terms of a workable solution?

0 comments:

Post a Comment