How to output information in JavaScript (Information confirmation box-prompt input box-document flow output) _javascript tips

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.