How to output information in JS
1. Document Flow output
document.write (' Hello ');
2. Output Information 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 you want to enter the Sina Network '); Confirm ("");
if (f) {
Location.href = ' http://www.sina.com.cn ';
}
4. Prompt input Box
Window.prompt
var n = window.prompt (' Please enter age ', 18);
if (n>=18) {
document.write (' Welcome to You young ');
}
5, control the label, directly on the label output,
by document.getElementById (' id ') to find the object tag, you can directly control the value inside, to output
SetInterval (function () {document.getElementById (' TTT '). InnerHTML = "Current time:" +new Date (). tolocalestring ();},1000);
<script>
document.getElementById (' uname '). Value = "Anon";
</script>
6. Output the information directly to the title
Document.title = "Hello";
How to output information in JavaScript-Information confirmation box-prompt input box-document flow output