开发者

Redirect to Browsers Homepage

I am working on an asp.NET 4.0 Web Application, using C#. I would l开发者_如何学编程ike to redirect the user to the homepage of his browser. Is this possible?

This will be done because internally we are using an intranet, and we would like to make it redirect to that intranet without having to hard code it and since the homepage is by default the url of the intranet, it would be better if we could use the homepage instead of hardcoding it.

EDIT:

We are using IE here, and will not change most probably as that is the standard. So as long as it works with all IE Versions, it's fine.


Use Javascript to return to the user's home page,

e.g.

 function goHome(){
      if (window.home) { 
        window.home(); 
      } else { 
        window.location = "about:home"; 
      }
    }

and then call the JS goHome() function somewhere on the page (or even on a hyperlink).


As stated above, use the about:home uri.

Another solution would be to store the intranet url in the web.config and use this value. Then if it ever changes you will only need to change it in one place.


As far as i know it is not possible (been researched alot). But if all homepages are the same why not simply use META REFRESH?

EDIT Try linking to this: About:home

<a href="About:home">Go home!</a>

worked for me in IE9

EDIT 2: Sending user to their browser's Home Page using Javascript This will get you started for firefox and safari

EDIT 3:

Response.Redirect("about:home", false);


You cannot redirect server side to a users homepage.

SERVER <> USER (server is not the user)

Therefore the server cannot know what the user's homepage is.

So if you you use some sort of javascript redirect, then you sort of can redirect to home, but its a little glitchy.

All in all there is no cross-browser way to redirect to a user's homepage.


You Can't!

You can't retrieve the user home page because of Security and Privacy issues, and there is no Cross-browser work around.

What you can?

You can redirect to any page, so you can simply redirect to your intranet home page. its also more future proof so that if your intranet homepage changes you just have change to redirect to the new address instead of changing every single machines home page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜