Because the Chrome,safari,opara browser does not support automatic "set as Home" & "Add Favorites". So we can only try, catch a moment, give a wrong hint! It's perfect.
In other IE, many people have also encountered it window.external.addFavorite. will be the problem of error. So I have to throw out the message.
Add to Favorites:
Copy Code code as follows:
function Addfavorite () {
if (document.all) {
try{
Window.external.addFavorite (Window.location.href,document.title);
}catch (e) {
Alert ("Join collection failed, please use Ctrl+d to add");
}
}else if (Window.sidebar) {
Window.sidebar.addPanel (Document.title, Window.location.href, "");
}else{
Alert ("Join collection failed, please use Ctrl+d to add");
}
}
Set as homepage:
Copy Code code as follows:
function setHomePage () {
if (document.all) {
Document.body.style.behavior= ' url (#default #homepage) ';
Document.body.setHomePage (WINDOW.LOCATION.HREF);
}else if (Window.sidebar) {
if (Window.netscape) {
try{
Netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconnect");
}catch (e) {
Alert ("This action is rejected by the browser and if you want to enable it, enter About:config in the Address bar and then signed.applets.codebase_principal_support the value to true");
}
}
var prefs = components.classes[' @mozilla. Org/preferences-service;1 '].getservice (components. Interfaces.nsiprefbranch);
Prefs.setcharpref (' Browser.startup.homepage ', window.location.href);
}else{
Alert (' Your browser does not support automatic setting of the home page, please use the browser menu manually set! ');
}
}