Methods for outputting information in javascript-confirmation box-Prompt input box-Document Stream output, javascript input box

Source: Internet
Author: User

Methods for outputting information in javascript-confirmation box-Prompt input box-Document Stream output, javascript input box
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 ";
Javascript message prompt box code I suddenly forgot the code is like this: javascript ('this is the prompt box content ')

<Script type = "text/javascript">
Alert ("this is the content of the prompt box ")

</Script>

Let me see why the javascript code cannot read the content in the input box?

Document. getElementsByName method. You can see that Elements is a complex number and an array is obtained!
GetElementByID is recommended for access with a single tag
Generally, name is used in server scripts, and ID is used in client scripts.

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.