[Javascript] Make This Site Your Home Page Button
1. Set homepage only for IE
Make this site your <a href="javascript:history.go(0)" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://aspnet-fix.blogspot.com/');">Home Page</a>Test: Make this site your Home Page
2. Set homepage for FireFox
If config: signed.applets.codebase_principal_support = true
<script language="javascript"> function setHomepage() { if (document.all) { document.body.style.behavior='url(#default#homepage)'; document.body.setHomePage('http://aspnet-fix.blogspot.com/'); } else if (window.sidebar) { if(window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch(e) { alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of 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','http://aspnet-fix.blogspot.com/'); } } </script>Test: Home Page
3. How about Chrome?
Chrome not allow to set homepage by javascript!
4. Using bookmark
// Add to Bookmark function add_bookmark( a ) { title = document.title; url = document.location; try { // IE window.external.AddFavorite( url, title ); } catch (e) { try { // Mozilla Firefox window.sidebar.addPanel( title, url, "" ); } catch (e) { // Opera if( typeof( opera ) == "object" ) { a.rel = "sidebar"; a.title = title; a.url = url; return true; } else { // Unknown (Chrome, Safari,...) alert( 'Press Ctrl-D to add page to your bookmarks' ); } } } return false; }
<a href="#" onclick="return add_bookmark(this);">Add to bookmarks</a>Test Add to bookmarks
P/S: Today users don't like set your website to home page, because search engine and many bookmark services
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment