Javascript Prompts | ||
| ||
| Follwing example will bring up a window asking the question of your choosing, with a space for the viewer to answer. The second set of quotes allows you to enter a default answer. If you leave it blank, the viewer will just see an empty box ready to be typed in. This is usually done before the page loads, so that you can write the answer they give into your page. <SCRIPT language="JavaScript"> <!--hide var yourname= prompt('Please enter your name, so you can get a special greeting', ' '); if ( (yourname==' ') || (yourname==null) ) { yourname="Dude"; } //--> </SCRIPT> </HEAD> <BODY> <SCRIPT language="JavaScript"> <!--hide document.write("<CENTER><H1>Hello, " + yourname + " ! Welcome to My Page! </H1></CENTER>"); //--> </SCRIPT> </BODY> | ||
| | ||
| |