Solved

Code to set default homepage

Posted on 2008-06-19
9
849 Views
Last Modified: 2012-06-27
Hi,

I need a function (I presume in JavaScript) that sets a web site I'm making as the default homepage both in Firefox and Internet Explorer by clicking a link.

Problem is that googling, I can only find code that works in Intenet Explorer.

Does anyone knows of some piece of code that works both in Firefox and Internet Explorer ?

Any help would be appreciated.

Warm Regards,
Mário Gamito
0
Comment
Question by:angelsofgrace2006
  • 4
  • 4
9 Comments
 
LVL 42

Expert Comment

by:David S.
ID: 21821290
Only IE would provide a feature like that.

All you can do is ask your users to do it manually in Firefox and other browsers.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 21821387
@Kravimir: Love your sense of humor!

This page has a fairly comprehensive collection of links for various browsers.
http://www.afscme.org/about/4321.cfm
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 21821446
Of course, in the age of tabbed browsing, simply making a bookmark might be close enough.  And if you really wanted to be pushy about it (not recommended) you might be able to trigger the javascript with body onload or some similar action.  Like I said, not recommended.  Better to let your clients click a link.
<script language="JavaScript" type="Text/Javascript"><!-- // Hide script from older browsers 
var urlAddress = "http://www.XXX.html"; 
var pageName = "Free Lunch"; 
function addToFavorites() { 
    if (window.external) { 
        window.external.AddFavorite(urlAddress,pageName) 
    } else { 
        alert("Sorry! Your browser doesn't support this function."); 
    } 
} // --></script>
 
 
<a href="javascript:addToFavorites()">Bookmark This Page</a>

Open in new window

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:angelsofgrace2006
ID: 21821455
Hi,

That's not true. It might be tricky, but possible.
Go to http://www.yahoo.com with Firefox.

Regards,
Mário Gamito
0
 

Author Comment

by:angelsofgrace2006
ID: 21821476
Hi Ray,

Thank you for your answer, but that's not what I've asked. I already wrote the code to add the site to Bookmarks(FF)/Favorites(IE).

What I want is to click on a link and set the site as the default browser's homepage.

Best Regards,
Mário Gamito
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 21821724
Mario: I looked at Yahoo with FF, but couldn't find a clickable link.  Instead, with a little searching, I found this:
http://www.yahoo.com/bin/set?home=my.yahoo.com&prop=My+Yahoo! 

Give me a little more of a clue to what you found at Yahoo.

Cheers, ~Ray
0
 

Author Comment

by:angelsofgrace2006
ID: 21821817
Hi Ray,

Go to http://www.yahoo.com with Firefox and click on "Make Y! your home page".

It seems that this the only technique available to do the trick in Firefox.
I also found it in other places, loke http://www.aeiou.pt
It's a portuguese site. In Firefox you'll have to drag the house icon to the Firefox "Home" button to set it as the default homepage, just like in Yahoo's.

Warm Regards,
Mário Gamito
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 21822368
Mario:

Sorry, I don't get a link to "Make Y! your home page" - it's not showing on my browser, and I searched the Yahoo page -- the text just isn't there.

But this seems to work in FF (you have to drag the link and confirm the change).  You can see it in action here: http://www.laprbass.com/RAY_homepage.html

Does that help? ~Ray
<html>
<body>
 
<script language="JavaScript1.1" type="text/javascript">
//<![CDATA[
		if (document.all) {
			document.write('<a class="a" href="javascript:history.go(0);" onclick="');
			document.write("this.style.behavior='url(#default#homepage)';this.setHomePage('"+document.location.href+"'");
			document.write(');">');
			document.write('Make This Your Homepage<\/a>');
		} else if (document.getElementById) {
			document.write('<a href="'+document.location.href+'" onclick="alert(');
			document.write("'Drag that link onto your Home Page Icon to Make '+document.location.href+' Your Homepage')");
			document.write(';return false;">Make This Your Homepage<\/a>');
		}
//]]>
</script>
 
</body>
</html>

Open in new window

0
 

Author Comment

by:angelsofgrace2006
ID: 21823341
Hi Ray,

Thank you so much for your answer.
Indeed, it did the trick :)

500 point well woned :)

Warm Reagrds,
Mário Gamito
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question