To determine and suppress the effect of a cue box:
In many web pages have this effect, when clicking on a button or other objects will pop up a prompt box, if click OK to continue to execute the established program, if the click Cancel will cancel the execution, the code example is as follows:
<!DOCTYPE HTML> <HTML> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <Metaname= "Author"content= "http://www.51texiao.cn/" /> <title>Ok and cancel prompt box</title><styletype= "Text/css">Div{width:150px;margin:0px Auto;}a{font-size:12px;Color:Blue;}</style><Scripttype= "Text/javascript">window.onload=function(){ varMyLink=document.getElementById ("mytest"); Mylink.onclick=function(){ if(Confirm ("Are you sure you want to visit Ant tribe?")) { return true; } Else { return false; } }}</Script></Head><Body> <Div><ahref= "Http://www.softwhy.com"ID= "MyTest">Click to jump to Ant tribe</a></Div></Body></HTML>
In the above code, when clicking on the link will pop up a prompt box, if clicked OK will visit Ant Tribe homepage, otherwise will not be visited. The core of this function is to use the Confirm (), the parameter value is the text content of the prompt box. Here is a brief introduction to the above code principle:
I. When clicking on a link, the onclick event handler that is bound to the a element is called.
Two. In the event handler function, since confirm () returns True when the OK button is clicked, clicking Cancel will return False, then the IF statement will choose to execute an IF statement or else statement based on the return value of confirm ().
The original address is: http://www.51texiao.cn/javascriptjiaocheng/2015/0405/127.html
Determining and canceling the cue box effect