javascriptpopupwindow.onunload

javascript problem related to pop window


I need a pop window which could not be refreshed by user. for that i am trying this:

function openNewWindow(href){
        alert("hello here");
        var newWindow = window.open(href, 'newWindow', 
        'toolbar=no,location=no,directories=no,status=no, menubar=no,resizable=no,width=1024,height=400');
        return false;
    }

<a onclick="return openNewWindow(this.href);" href="newPage.html" >Click me</a>

newPage.html

window.onunload = check;
    function check(){
        alert("hey");
        return false;
    }

Here alert is generated when i try to reload the browser. but return false; is not working.

Or if it is possible to not to have Navigation bar in newly pop up window.

So please help


Solution

  • newWindow.onload = setUnloadHandler;

    It's not clear from your example, but probably newWindow contains a document from another site. You can't script into it due to the Same Origin Policy.

    Also, browsers won't let you do anything to prevent an unloading in the onunload handler, because it's obnoxious and users hate it—remember the old days when this was allowed, and abused to generate endless uncloseable porn popup loops?

    You can't get an unrefreshable window. What is your purpose in trying to do so?