Solved

Programatically Link to Browser's Default Homepage

Posted on 2007-03-20
7
277 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now