Compatible with all browsers set homepage Favorites JS Code

Source: Internet
Author: User

We found that the traditional collection of the site button under the 360 browser has no effect, but the 360 browser user base is very large. So we found on the Internet a compatible with all the browser's favorite site solution, the specific functions are as follows:

Set homepage and bookmark this site JS code compatible IE,CHROME,FF,360, etc.

Put the following code into the page or create a new JS file

<script type= "Text/javascript" >

Set as homepage

function Sethome (obj,url) {

try{

Obj.style.behavior= ' url (#default #homepage) ';

Obj.sethomepage (URL);

}catch (e) {

if (Window.netscape) {

try{

Netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconnect");

}catch (e) {

Alert ("Sorry, this operation was rejected by the browser!") \ n \ nyou Enter "About:config" in the browser address bar and return and set [Signed.applets.codebase_principal_support] to ' true ');

}

}else{

Alert ("Sorry, the browser you are using cannot complete this operation.") \ n \ nyou need to manually set the ' +url+ ' to the home page. ");

}

}

}

Bookmark this site bbs.ecmoban.com

function addfavorite (title, URL) {

try {

Window.external.addFavorite (URL, title);

}

catch (e) {

try {

Window.sidebar.addPanel (title, URL, "");

}

catch (e) {

Alert ("Sorry, the browser you are using cannot complete this operation.") \ n \ nthe bookmark failed, please use Ctrl+d to add ");

}

}

}

</script>

Page Call:

<a href= "javascript:void (0);" onclick= "sethome (This, ' Http://www.cnblogs.com/tnnyang ');" > Homepage </a>

<a href= "javascript:void (0);" onclick= "Addfavorite (' My Site ', location.href)" > Favorites </a>

Compatible with all browsers set homepage Favorites JS Code

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.