Javascript| Browser
26 Accessing the 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:}
: </script>
Do 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.liu21st.com/";
3: </script>
35 Add Page Load Progress window
1:
2:
3: <script language= ' JavaScript ' >
4:var placeholder = window.open (' holder.html ', ' placeholder ', ' width=200,height=200 ');
5: </script>
6: <title>the Main page</title>
7:
8: <body >
9: <p>this is the main page</p>
: </body>
One: