Solved

Programatically Link to Browser's Default Homepage

Posted on 2007-03-20
7
301 Views
Last Modified: 2012-06-22
On a webpage (ASP.Net, VB.Net), one of the buttons I have is a 'CANCEL' button.  When it is clicked, I need to take the internet user back to whatever their (IE) deault homepage is setup as.  How do I obtain the URl that is set as the user's default homepage ?   Can someone please tell me how to do this ?

Thank you. msyed1.
0
Comment
Question by:msyed1
7 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 18853957

First, the only way to do this is on the client side.  While you can redirect using the server side redirect, you still need to talk with the client browser to get their home page.  This is why I reccomend using Javascript on the client browser.

The way that I've done it in the past is to assume that the default home is the first page loaded when a user starts their browser.   This is not always true, but it's close enough.


The javascript command is history.go(<int>)

The <int> in question is the number of pages to go forward or backward.  1 goes forward 1 url in history, and -1 goes backward 1 page in history.

So...
        history.go(-1*history.length)

goes back to the very first page that the user saw when they opened their browser.


putting it all together:

[code-behind]
<buttonClick>
   string str = "javascript: history.go(-1*history.length)"
   Page.RegisterClientScriptBlock(str, "GoHome")


0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 168 total points
ID: 18853963
D'Oh!

You are using VB.net...


[code-behind]
<buttonClick>
   Dim str as string
   str = "javascript: history.go(-1*history.length)"
   Page.RegisterClientScriptBlock(str, "GoHome")
0
 
LVL 14

Assisted Solution

by:steveberzins
steveberzins earned 166 total points
ID: 18855249
assuming only IE, and also only windows...

security settings will not allow you to do this in most cases, this value is stored in the registry, and that is the only way I know of you can get at it, and by default, browser security setting will not allow you to access the registry, even if all you want to do is read it, not even change it...

IF, you can get the users to add your site to their trusted sites, this should work, and in the case of Vista, and maybe XP as well, I'm not sure, I think you'd also have to have them allow activex objects not marked as safe for scripting to be created. not something you're going to get anyone but the most clueless, and security 'unwise' to do for you.

<script language="jscript">
<!--//
function HomePage() {

    var WshShell = new ActiveXObject("WScript.Shell");

    var homepage = WshShell.RegRead ("HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\Start Page");

    alert(homepage);

}
//-->
</script>

so, the best option is probably one of the above to just send them back to the first page in their history, or... if you can get your company, I'm going to assume you are doing this for a company of some sort, and they are doing legitimate business, you could put this into an activeX control, pay to have it signed, and then get the users to trust you enought allow it to be installed, and, and, and then you could have this exposed through that control to do this.
0
 
LVL 2

Assisted Solution

by:forrest321
forrest321 earned 166 total points
ID: 18857333
Why not just check the browser version and redirect based on a previously determined home page for that particular browser?  I understand this is not nearly a perfect answer, but AFAIK browsers do not store what page(s) they were intended to set as home upon installation in a manner that is accessible to web sites they visit.
0
 

Author Comment

by:msyed1
ID: 18885238
Thank you for all the suggestions.  I haven't had a chance to test any of the suggestions yet.  Will assign points after I have tried the suggestions.  Thanks. msyed1.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

733 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