Common JavaScript selections (2)

Source: Internet
Author: User

(1) set as Homepage
 
<A href = http://www.thwd.net
Onmouseover = This. style. Behavior = "URL (# default # homepage )";
This. setHomePage ("http://www.thwd.net/";);> set to home </a>

(2) Add to favorites

<A href = javascript: window. External. AddFavorite ("http://www.jzzy.com";, "Site Resources")> Add to favorites site </a>

(3) display scroll information in the window status area
(1) Add in the bodyCode
<Script
Language = "JavaScript">
VaR MSG = "welcome to the website resources network. Here you will have some gains! ";
VaR I = 1

Function scroll ()
{
Mess = msg. substring (I, MSG. Length) +"
"+ Msg. substring (0, I)
Window. Status = mess
I ++;
If (I> = msg. length)
I = 1; // set non-stop scrolling
SetTimeout ("scroll ()", 200); // you can specify the scroll speed.
}
</SCRIPT>

(2) In the Body Tag:
<Body onload = "scroll ()">
(4) Add the current time to the page

<Script language = "JavaScript">
TDY = new date ();

Document. Write ("current time:", TDY. gethours ());

Document. Write (":", TDY. getminutes ());

Document. Write (":", TDY. getseconds ());
</SCRIPT>

(5) forward and backward buttons
<Input type = "button" value = "<-"
Onclick = "history. Go (-1)">
<Input type = "button" value = "->"
Onclick = "history. Go (1)">

(6) Date of last modification to the page
<Script language = "JavaScript">

Document. Write ("Last edit date of this page :");
Document. Write (document. lastmodified)

</SCRIPT>

(7) forward and backward buttons
<Font onclick = "history. Go (-1)"> previous page </font>

<Font onclick = "history. Go (-2)"> previous two pages </font>
<Font
Onclick = "history. Go (-3)"> first three pages </font>
<Font
Onclick = "history. Go (1)"> next page </font>
<Font
Onclick = "history. Go (2)"> last two pages </font>
<Font
Onclick = "history. Go (3)"> last three pages </font>
You can also set back and move forward multiple steps.

(8), mouse events
onmouseover = "alert (" Write to me "); return true "> mailbox
place the cursor to display the Warning Information

(9) Obtain browser attributes
navigator. appcodename = undefinednavigator. appname = Microsoft Internet
assumernavigator. appversion = 4.0 (compatible; MSIE 5.0; Windows 98;
digext) navigator. appagent = undefined
(10) print the entire page
onclick = "javascript: window. print () "> Print this page
(11) view Source Code
type = "button" name = "View" value = "view source code on this page"
onclick = "window. location = "view-source:" + window. locati On. href "
class =" pt9 ">
(12). Refresh the page
onclick =" history. go (0) "> refresh this page
(13), background color conversion
type = "button" value = "background color conversion" onclick = "bgbutton () ">

(14th) display Information on title

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.