Link to home
Start Free TrialLog in
Avatar of msyed1
msyed1

asked on

Programatically Link to Browser's Default Homepage

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.
Avatar of _TAD_
_TAD_


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")


ASKER CERTIFIED SOLUTION
Avatar of _TAD_
_TAD_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msyed1

ASKER

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.