JavaScript Browser output

Source: Internet
Author: User
Tags date split time and date window domain
Javascript| Browser 26 Access Document object
1<script language= "JavaScript" >
2 var myurl = document. URL;
3 Window.alert (Myurl);
4</script>
27 Dynamic Output HTML
1<script language= "JavaScript" >
2 document.write ("<p>here ' s Some information about this document:</p>");
3 document.write ("<ul>");
4 document.write ("<li>referring Document:" + document.referrer + "</li>");
5 document.write ("<li>domain:" + document.domain + "</li>");
6 document.write ("<li>url:" + document. URL + "</li>");
7 document.write ("</ul>");
8</script>
28 Output Line Wrapping
1 Document.writeln ("<strong>a</strong>");
2 Document.writeln ("B");
29 Output Date
1<script language= "JavaScript" >
2 var thisdate = new Date ();
3 document.write (thisdate.tostring ());
4</script>
30 time zone for the specified date
1<script language= "JavaScript" >
2 var myoffset =-2;
3 var currentdate = new Date ();
4 var useroffset = Currentdate.gettimezoneoffset ()/60;
5 var timezonedifference = Useroffset-myoffset;
6 currentdate.sethours (currentdate.gethours () + timezonedifference);
7 document.write ("The time and date in the", Europe is: "+ currentdate.tolocalestring ());
8</script>
31 Set Date output format
1<script language= "JavaScript" >
2 var thisdate = new Date ();
3 var thistimestring = thisdate.gethours () + ":" + thisdate.getminutes ();
4 var thisdatestring = thisdate.getfullyear () + "/" + thisdate.getmonth () + "/" + thisdate.getdate ();
5 document.write (thistimestring + "on" + thisdatestring);
6</script>
32 Reading URL Parameters
1<script language= "JavaScript" >
2 var urlparts = document. Url.split ("?");
3 var parameterparts = Urlparts[1].split ("&");
4 for (i = 0; i < parameterparts.length; i++) {
5 var pairparts = parameterparts[i].split ("=");
6 var pairname = pairparts[0];
7 var pairvalue = pairparts[1];
8 document.write (Pairname + ":" +pairvalue);
9}
10</script> you still think HTML is stateless?

33 Open a new Document object
1<script language= "JavaScript" >
2 function NewDocument () {
3 Document.open ();
4 document.write ("<p>this is a New document.</p>");
5 Document.close ();
6}
7</script>
34 Page Jump
1<script language= "JavaScript" >
2 window.location = "http://www.velee.cn";
3</script>
35 Add Page Load Progress window
12 3 <script language= ' JavaScript ' >
4 var placeholder = window.open (' holder.html ', ' placeholder ', ' width=200,height=200 ');
5 </script>
6<title>the Main page</title>
78<body onload= ' placeholder.close () ' >
9<p>this is the main page</p>
10</body>
11

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.