The method of output information in JS is as follows:
1. Document Flow output
document.write (' Hello ');
2. Output Information Prompt box modal dialog box
Window.alert (' to output the displayed content '); or alert (' to output the displayed content ');
alert (n);
3, Information confirmation box
var f = window.confirm (' Whether to enter Sina net '); Confirm ("");
if (f) {
location.href = ' http://www.sina.com.cn ';
}
4. Prompt input Box
Window.prompt
var n = window.prompt (' Please enter age ', a);
if (n>=18) {
document.write (' Welcome to You young man ');
}
5, the control label, the direct output on the label,
by document.getElementById (' id ') to find the object tag, you can directly control the value inside, for output
SetInterval (function () {document.getElementById (' TTT '). InnerHTML = "Current time:" +new Date (). tolocalestring ();},1000);
<script>
document.getElementById (' uname '). Value = "Anon";
</script>
6, the information directly output to the title
Document.title = "Hello";
The above is a small set of JavaScript to introduce the output information method (Information confirmation box-prompt input box-document flow output), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!