Ask for help..... Super simple a problem..

Click on the upper right corner of the fork to close the browser will pop up when a confirmation from the dialog box, click Cancel don't close, point to determine if I will execute the corresponding code, for example, to jump to a particular page... Excuse me how, I know that the onbeforeunload method, but is not a capture point is determined or cancel... Help ah

Started by Emma at February 02, 2016 - 4:43 AM

To determine the point is not to close the browser.?
Don't quite understand what you mean

Posted by Randall at February 06, 2016 - 5:16 AM

In onbeforeunload this event with the confirm pop-up boxes
if(confirm("Sure you want to close it? ")) {
    //Click "OK" implementation of the code
}else {
    //"Cancel" implementation of the code

Posted by Oprah at February 17, 2016 - 5:40 AM

If the point is to jump to a particular page, it is not that the browser is closed off, this is security, not allowed

Posted by Ruth at November 10, 2016 - 11:22 PM

At present, also cannot be executed through JS does not close the browser method, method is not close all browser provides, because the browser doesn't want JS to bring a cannot close the page to the client.
So the following code will have a problem:
You point to determine, executive program, and then close the page
You click Cancel, the browser will pop up again hint, whether to close the page
   if(confirm("Sure you want to close it? ")) {
}else {
   return "Are you sure you want to leave? ";

Or, the browser gives tips, JS is unable to obtain the user selection. (if the user is determined, the page immediately shut down, unable to perform any JS; if the user click Cancel, JS no monitor shows.

Posted by Rory at November 24, 2016 - 12:08 AM

Of course, for an idea, may change to achieve.
According to the sequence of events, is the first implementation of onbeforeunload. If the user chooses to close to onunload. So the following wording may change to achieve the effect you want.
   return "Are you sure you want to close it? ";

Posted by Rory at December 08, 2016 - 12:59 AM

Can not be achieved at present. . . .

Posted by Gene at December 23, 2016 - 1:20 AM

This is a method

Posted by Ruth at December 26, 2016 - 2:08 AM

I want to close the page you gave me to open a new page

Posted by Lareina at January 02, 2017 - 3:01 AM

I need an answer to the question, attention.

Posted by Spike at January 04, 2017 - 3:45 AM

That is, it belongs to the user will rape behavior, is a rogue behavior. All against the will of the user requirements design is play rascal, is the need to correct the demand.

Onbeforeunload return a string has to remind the user function, users click on the left now, is determined to leave, the program must then open in a new window, will only make the user more hate.

Reasonable onbeforeunload using places, such as you write an email, and not saved, careful not to cross off label page, onbeforeunload can remind the user friendly: "kiss, mail didn't save it also". If the user is determined to leave, then let him go.

Posted by Woodrow at January 05, 2017 - 3:33 AM