Add JS Code to favorites and set as Homepage

Source: Internet
Author: User

Add to favorites JSCode:

 

Function AddFavorite (Surl, stitle ){
Try {
Window. External. AddFavorite (Surl, stitle );
}
Catch (e ){
Try {
Window. Sidebar. addpanel (stitle, Surl ,"");
}
Catch (e ){
Alert ("failed to add to favorites, please add with Ctrl + D ");
}
}
}

Reference <li class = "Li1"> <a class = "A1" href = "javascript: AddFavorite (window. location, document. title); "> Add this information to favorites </a> </LI>

 

Set as homepage JS Code:

Function sethome (OBJ, VRL ){
Try {
OBJ. style. Behavior = 'url (# default # homepage) '; obj. setHomePage (VRL );
}
Catch (e ){
If (window. Netscape ){
Try {
Netscape. Security. privilegemanager. enableprivilege ("universalxpconnect ");
}
Catch (e ){
Alert ("this operation is rejected by the browser! Enter about: config in the address bar of the browser and press enter to set [signed. Applets. codebase_principal_support] to true ");
}
VaR prefs = components. classes ['@ mozilla.org/preferences-service%1'%.getservice

(Components. Interfaces. nsiprefbranch );
Prefs. setcharpref ('browser. startup. homepage', VRL );
}
}
}

Reference on the front-end page:

<Li class = "Li1"> <a href = "#" onclick = "javascript: sethome (this, window. location) "> set to homepage </a> </LI>

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.