Javascript example Tutorial: Set the homepage to the home page and add it to the favorites folder

Source: Internet
Author: User

Do you often see this situation? When you press a link and the prompt information tells you whether you are willing to set this page as the homepage. If you choose yes, in the future, the web page of the browser will become the current page.

Take a look at the following simpleSource code:

<A class = "chlnk" style = "cursor: Hand" href = "#" onclick = "this. style. behavior = 'url (# default # homepage) '; this. setHomePage ('HTTP: // www.5dmedia.com '); Return false; ">
<Font color = "ff6600" size = "2"> [add this site as the homepage] </font>
</A>

Enter the preceding information between the <body> and </body> labels.CodeYou can.

The URL (# default # homepage) in the above Code points to the current page, and this. setHomePage ('HTTP: // www.5dmedia.com ') means to set the home page to http://www.5dmedia.com. In this place, you can write your own home address.

Take a look at the running results:

Page when no mouse clicks

Prompt displayed after clicking the mouse

Add your homepage to the favorites folder of the visitor so that the visitor can access your site again.
The Code is as follows:

<Script language = JavaScript>
Function bookmark ()
{If (document. All)
// Check whether the browser is ie. If yes, execute the following statement:
Window. External. AddFavorite ('HTTP: // www.5dmedia.com ', "5d multimedia ");
// Call the AddFavorite () function to add the website to the favorites folder
}
</SCRIPT>

Enter the preceding code between the

The <body> tag code is used to trigger an event:

<Body>
Welcome to 5d multimedia
<A href = "javascript: bookmark ()"> [add this site to favorites] </a>
</Body>

Create a new .htm document, enter the above Code, and change the URL and website name to your own one. When you click this connection, the following window appears:

When the mouse does not click the link

After clicking the link

 

Related Article

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.