aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

how to set default home page in IE and Mozilla using JavaScript in

Dec 1, 2011

Here I will explain how to set default home page in browser using JavaScript in


In many major websites we will see link like “Set as a home page” if we click on that home page link that will automatically change our browser default home page url to their particular page url. In IE browser we can easily set home page just by simple code but Mozilla we don’t have a chance to set home directly because of security concerns. If we want to set the home page in Mozilla first we need to set signed.applets.codebase_principal_support to true then run the below code to set home page initially that is in false mode. 

To enable this property in Mozilla follow below steps

1.      1) First open Mozilla browser and type about:config in address bar and click enter

2.      2) Now it will show some warning message click ok and now search for signed.applets.codebase_principal_support right click on it and select Toggle now Value will change to true

3) Once that property set then run the below code and click on set as home page button it will automatically will set your url as the home page.  

Write the below code in your page to set home page in your IE and Mozilla browsers 

<html xmlns="">
<head id="Head1" runat="server">
<title>Add BookMark it Link to your website using JavaScript</title>
<script language="javascript" type="text/javascript">
function setHomepage() {
//Condition to set home page in IE
if (document.all) { = 'url(#default#homepage)';
//Condition to set home page in Mozilla
else if (window.sidebar) {
if (window.netscape) {
try {"UniversalXPConnect");
catch (e) {
alert("this action was aviod by your browserif you want to enableplease enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
var prefs = Components.classes[';1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', '');
<form id="form1" runat="server">
<input type="button" value="set home page" onclick="setHomepage();" />
After add above code run your application and check your output it will work for you



If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Abhinavsingh993 said...

Great Article Sir, Your always great and will be great, Thank you for this article
Your Biggest Fan on the earth,
Abhinav Kumar Singh

Darpan Samani said...

Hi suresh nice article but internet explorer show me one popup to confirm to set home page i want to remove that popup and directly set home page without popup??? it is possible

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.