Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a Home Page 1

Status
Not open for further replies.

DarkMan

Programmer
Apr 13, 1998
222
US
Does anyone know how to set a browser's home page from a link with javascript or something similar? I've looked all over the place with no luck.<br>
<br>
Thanks in advance.<br>
<br>
Doug
 
Depends on what type of link that you mean... do you mean jump links with a drop down menu to different links? I can help you with that; it's a lifesaver for a huge web site...<br>
<br>
<br>
-Kyrene
 
Basically, I'm looking for a way to save a page in a browser so that it pops up automatically when a user opens the brower.<br>
<br>
I've seen ways to script bookmarking a page, and I'm sure I've seen pages that let you click on a link to make it your home page, but I have yet to find any kind of script that will make a page your home page....
 
Oh!!! Sort of like the "click to automatically bookmark this site" links that I've seen?<br>
<br>
Ok...that I don't know how to code... but next time I see one of those, I'll view the document source and try to figure it out. I think I know what you're talking about....<br>
<br>
<br>
-Kyrene
 
Thanks...:) If I find one, I'll post it here also...
 
Doug-<br>
Now that I hear it mentioned, I remembered that I saw such a link on the page: I'll go there right now, check it out to see if I can get it to a usable point for you, then post it here if I can.
 
OK, here's a link with JavaScript enhancement, along with the other necessary JavaScript info to do what you're wanting:<br>
<br>
&lt;a href='#' onClick="makehomepage(window.location); return false"&gt;Click here to set this as you home page&lt;/a&gt;<br>
<br>
&lt;script language=javascript&gt;<br>
&lt;!--<br>
<br>
function makehomepage(url)<br>
{<br>
//Set variable for error messages<br>
var pls=" Please follow the instructions below to set your home page manually.";<br>
<br>
//Detect carrier;<br>
if (navigator.appName== "Netscape" && navigator.appVersion.charat(0) &gt;= 4)<br>
{<br>
<br>
//Set home page<br>
window.onerror=Oops();<br>
netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");<br>
navigator.preference("browser.startup.homepage", home_page_url);<br>
window.onerror=Oops();<br>
alert('Congratulations, your new home page has been set successfully.');<br>
return false;<br>
<br>
//Create function to alert when something doesn't work;<br>
function Oops()<br>
{<br>
instruct("I'm sorry, there was an error while setting your new home page."+pls);<br>
}<br>
<br>
//Create function to alert/redirect when an error occurs;<br>
function instruct(message)<br>
{<br>
alert(message);<br>
window.location.href="/sethomepage.html"<br>
}<br>
} else {<br>
instruct("I'm sorry, your browser does not allow us to set your home page automatically."+pls);<br>
}<br>
<br>
//--&gt;<br>
&lt;/script&gt;<br>
<br>
<br>
Just a note: the only thing missing here is the page: /sethomepage.html<br>
I have left it up to you to create a page that describes how to set your site as a user's home page if you would like, or to simply delete the lines:<br>
window.location.href="/sethomepage.html"<br>
AND<br>
//Set variable for error messages<br>
var pls=" Please follow the instructions below to set your home page manually.";<br>
<br>
From the script if you would rather not make this page.<br>
<br>
Special note:<br>
If you DO delete these lines, you will need to set<br>
var pls = ''<br>
DO NOT just delete the variable declaration as this would lead to HIGHLY UNDESIREABLE effects.<br>
<br>
Feel free to contact me if you need any more assistance.<br>
<br>
-Robherc<br>
<br>
<br>
ICQ#: 34916735<br>
Work E-mail: robherc.work@angelfire.com
 
Thanks! I've been looking for a script like this for some time. You've really helped me out. I'll let you know how it goes once I've implemented it.<br>
<br>
Doug
 
Ok, let me know if I can be of anymore help!<br>
I'm sure there will be times when I need help with something too, so I think it's a really good practice to DO some helping before I NEED some :)<br>
I hope the script works well for you (Oh, BTW: the script that I gave you above is a modified version of a script that can be found at: it has been modified beyond copyright but, as it was originally made by Netscape, it doesn't work with IE, just Netscape 4.x)<br>
<br>
-Robherc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top