window

The window object provides three methods to display a simple dialog to the user alert() Displays
a message to the user and waits for the user to close confirm() Displays a button that asks the user to click OK
or cancel prompt() Displays a message waiting for the user to enter characters String and return that string

do{
   var name = prompt('What is you name?') //Get the string
   var correct = confirm ('You entered'.'+name+''.\n'+'Click Okay to proceed of Cancel to re-enter.') //get boolean value
}while(!correct)
alert('Hello,'+name) //output a text message

 

The methods confirm() and prompt() will block, that is, they will not return until the dialog they display is closed,
 meaning that the popup dialog code will stop

 

 

onerror is an error handler that outputs an error message to the browser's JS console if you attach a function to this property

As long as a JS error occurs in this window, the
onerror event handler will be called. The first parameter is a message describing the error. The
second is a string that stores the URL of the document where the JS code that caused the error is located. The parameter is
the number of lines in the document where the error occurred.

If the onerror handler returns a false, it notifies the browser event handler that the error has been handled.
No other action is required.

Now onerror is rarely used
// in a dialog box to pop up an error message but no more than three times
window.onerror = function (msg,url,line){
   if(onerror.num++<onerror.max){
      aler('ERROR:'+msg+'\n'+url+':'+line)
      return true
    }
}
onerror. max=3
onerror.num=0

The window object provides three methods to display a simple dialog to the user alert() Displays
a message to the user and waits for the user to close confirm() Displays a button that asks the user to click OK
or cancel prompt() Displays a message waiting for the user to enter characters String and return that string

do{
   var name = prompt('What is you name?') //Get the string
   var correct = confirm ('You entered'.'+name+''.\n'+'Click Okay to proceed of Cancel to re-enter.') //get boolean value
}while(!correct)
alert('Hello,'+name) //output a text message

 

The methods confirm() and prompt() will block, that is, they will not return until the dialog they display is closed,
 meaning that the popup dialog code will stop

 

 

onerror is an error handler that outputs an error message to the browser's JS console if you attach a function to this property

As long as a JS error occurs in this window, the
onerror event handler will be called. The first parameter is a message describing the error. The
second is a string that stores the URL of the document where the JS code that caused the error is located. The parameter is
the number of lines in the document where the error occurred.

If the onerror handler returns a false, it notifies the browser event handler that the error has been handled.
No other action is required.

Now onerror is rarely used
// in a dialog box to pop up an error message but no more than three times
window.onerror = function (msg,url,line){
   if(onerror.num++<onerror.max){
      aler('ERROR:'+msg+'\n'+url+':'+line)
      return true
    }
}
onerror. max=3
onerror.num=0

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326708994&siteId=291194637