www.webdeveloper.com
Results 1 to 2 of 2

Thread: close window warning

  1. #1
    Join Date
    Jan 2006
    Posts
    148

    close window warning

    I'm trying to get a script to work where if the browser is closed or they leave this site. They get a conf message. (Are you sure you want to leave, Y/N)

    Code:
                 $hdisplay .= "<script language='javascript'>\n";
    	$hdisplay .= "function onFeforeUnloadAction(){\n";
    	$hdisplay .= "var flag\n";
    	$hdisplay .= "var mesg ='You are closing the window. do you want to continue. Click Ok to close or click Cancel to stay back';\n";
    	$hdisplay .= "return mesg;\n";
    	$hdisplay .= "}\n";
    	$hdisplay .= "window.onbeforeunload = function(){if((window.event.clientX<0) || (window.event.clientY<0)){ return onBeforeUnloadAction();}\n";
    	$hdisplay .= "</script>\n";

  2. #2
    Join Date
    Feb 2011
    Location
    israel
    Posts
    157
    well, technically there's the onunload event (reference: http://www.w3schools.com/jsref/event_onunload.asp )
    but at least for me, it doesnt work when you close the page, but works when you press on a link to leave the page.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles