Solved

Code to set default homepage

Posted on 2008-06-19
9
850 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 110

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 110

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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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 110

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 110

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

740 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