Recently in the database, you need to give a "delete" link to increase the confirmation of the popup box, found on the Internet two methods:
1, first look at one of the most troublesome
<HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Untitled Document</title><Script>functioncon () {varCFM=Confirm ("are you sure ?"); if(CFM) {window.location.href="http://www.baidu.com"; }}</Script></Head><Body><ahref= "Javascript:con ()">Baidu Link</a></Body></HTML>
The principle of this method is to judge confirm true or false, if true, then I will put http://www.baidu.com, to the HREF, if False, then the HREF is a null value.
2, the simplest way to use the onclick attribute in the <a></a> tag
<href= "http://www.baidu.com" onClick= "return confirm (' Confirm? ')" > Baidu link </a>
The OnClick property in this method is similar to the onsubmit in the <form> form, and returns true to jump, return false you just stay where you are.
But if the application in the link database, both methods are not very useful, because the code involved in too many quotes, a variety of single and double quotation marks coexist, so here I summed up another way, with a function to add a confirmation link, relative to the database is more practical method , write confirm into a function
<HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Untitled Document</title><Script>functioncon () {varCFM=Confirm ("are you sure ?"); if(CFM) {return true; } Else { return false; }}</Script></Head><Body><aonclick= "return con ()"href= "Http://www.baidu.com">Baidu Link</a></Body></HTML>
The knowledge used in this place is not many, but in general the knowledge of data type is used, and the five big data types must be understood deeply
<Script>functionTo () {vara= 5; varb= "Nihao"; varC= function(){}; varD= NULL; vare= true; Alert (typeofa); //data type is numberAlert (typeofb); //data type is stringAlert (typeofc); //data type is functionAlert (typeofd); //data type is ObjectAlert (typeofe); //data type is Boolean}to ();</Script>
In fact, the data type is far more than the five kinds, the following figure can be broadly summarized
How to add "confirm" to hyperlinks in Web pages