Determining and canceling the cue box effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.