<script type= "Text/javascript" >
<!--
document.write ("When the browser does not support JS, the statement body will not be executed. <br/> ");
//single-line comment
/ * Multiline Comment * /
declaration format for variable: var variable name [= value];
var li_a =;
document.write (li_a + "<br/>");
document.write ("People <br/> Republic of China <br/>");
//Warning Box: Alert (n), no return value.
alert ("The people of China \ \");
//Confirm box: Confirm (n); Returns a Boolean value.
var lb_return = false;
Lb_return = Confirm ("Is it performed?");
if (lb_return) {
document.write ("executed <br/>");
}else{
document.write ("not implemented <br/>");
}
//Session box: Prompt (N,V); Returns the string, n is the cue message, and V is the initial value.
var ls_text = "";
Ls_text = prompt ("Please enter user name", "");
document.write (ls_text);
switch (ls_text) {
Case "Admin":
document.write ("You are the Administrator");
{break;}
Case "James":
document.write ("You are a programmer");
{break;}
Default:
document.write ("User name does not exist");
{break;}
}
-
</script>
<script type= "Text/javascript" src= "Javascript.js" ></script>
<body>
</body>
Warning boxes, confirmation boxes, session boxes in JavaScript