Set as homepage code and add to favorites code (compatible with various browsers)

Source: Internet
Author: User
I have tested that no error is reported in ie, but the cause is unknown. The error is reported in ie. I am working on it.

I have tested that no error is reported in ie, but the cause is unknown. The error is reported in ie. I am working on it.
Function Description:
Set the page as the homepage and add it to the favorites function. It supports ie, ff, chrome, safari, 360 security, qq, travel, and sogou browsers, incompatible with 360. Add the add-to-favorites feature in the compatible mode of quick Browser

Note:
Although it is compatible here, Some browsers do not support setting the page as a homepage using js and adding it to favorites. Users can only manually set these features in the browser or press the key, the Compatibility mentioned here refers to the js prompt when the browser has this setting.
Code:

Homepage |
Set as Homepage
| Add to favorites


// Add to favorites
Function AddFavorite (sURL, sTitle ){
SURL = encodeURI (sURL );
Try {
Window. external. addFavorite (sURL, sTitle );
} Catch (e ){
Try {
Window. sidebar. addPanel (sTitle, sURL ,"");
} Catch (e ){
Alert ("failed to add to favorites, please use Ctrl + D to add, or manually set in the browser .");
}
}
}

// Set as Homepage
Function SetHome (url ){
If (document. all ){
Document. body. style. behavior = 'url (# default # homepage )';
Document. body. setHomePage (url );
} Else {
Alert ("Hello, your browser does not support automatic page setting as the homepage function. Please manually set this page as the homepage in your browser! ");
}

}
Script

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.