Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

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.
0
msyed1
Asked:
msyed1
3 Solutions
 
_TAD_Commented:

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
 
_TAD_Commented:
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
 
steveberzinsCommented:
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
 
forrest321Commented:
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
 
msyed1Author Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now