Methods for outputting information in javascript-information confirmation box-Prompt input box-Document Stream output
How to output information in js
1. Document Stream output
Document. write ('hello ');
2. modal dialog box for the output information prompt box
Window. alert ('content to be displayed output'); or alert ('content to be displayed output ');
Alert (n );
3. Information confirmation box
Var f = window. confirm ('Do you want to enter xinlang net'); confirm ("");
If (f ){
Location. href = 'HTTP: // www.sina.com.cn ';
}
4. Prompt input box
Window. prompt
Var n = window. prompt ('enter your age', 18 );
If (n> = 18 ){
Document. write ('Welcome young people ');
}
5. control tags and output them directly on tags,
You can use document. getElementById ('id') to find the object tag. You can directly control the value and output it.
SetInterval (function () {document. getElementById ('ttt'). innerHTML = "current time:" + new Date (). toLocaleString () ;}, 1000 );
<Script>
Document. getElementById ('uname'). value = "Alias Name ";
</Script>
6. output the information directly to the title.
Document. title = "hello ";