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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Homepage

Status
Not open for further replies.

kamloops

Programmer
May 7, 2003
34
0
0
CA
Hi There,

I have an online form that I want to have a checkbox that when checked off sets the user's hoempage to a url that I specify and does nothing if it is unchecked...

What is the code to do this?

Thanks
 
You need the following style in your <head> section:
Code:
<STYLE>
@media all {
   IE\:HOMEPAGE {behavior:url(#default#homepage)}
}
</STYLE>

Then you need a function, in a script in the <head>:
Code:
function setHomePageToURL(theURL){
	browserHomePage.setHomePage(theURL);
	event.returnValue = false;
}

Put the following tag at the start of the <body>:
Code:
<IE:HOMEPAGE id=&quot;browserHomePage&quot; />

Then you can set up your checkbox to utilise it's onChange event to set the home page:
Code:
<input name=&quot;setHP&quot; type=&quot;checkbox&quot; value=&quot;[URL unfurl="true"]http://www.tek-tips.com&quot;[/URL] onClick=&quot;if(this.checked){setHomePageToURL(this.value);}&quot; />Check to set Home Page

Obviously IE only... not sure how to go about it in the lesser browsers ;-)
 
I get an object doesn't support this property or method.

It occurs in the function part

Your help is appreciated.

Tahnks
 
Sorry, forgot to mention that you'll need to use IE as an xml namespace in your opening <head> tag:
Code:
<html xmlns:ie xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;>[/URL]
 
It works but can I have it so t doesn't prompt them to set it... as chekcing it off should just do it.

Thanks alot
 
how would you feel if you went to a website and your home page was changed without you knowing?

And in answer to your question, no you can't (in IE anyway)- the user has to OK/Cancel homepage setting. The reason IE doesn't allow it to happen automatically should be clear from my first question :)


Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
clarkin is right, it would be rude to change someone's browser settings without asking. Therefore there is no way to do this in JavaScript. You would need an ActiveX control to obtain that sort of control over the browser.

If you are talking about a corporate environment where you may need to set the homepage of dozens or hundreds of users, you can use a policy creator/editor tool to achieve this at an operating system level.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top