开发者

How can I redirect to IE from other browsers?

I want to redirect to Internet Explorer from other brows开发者_C百科ers by JavaScript. How can I do that?


You can't.

In a standard security context, browsers provide no way of launching other programs (and a goodly number of systems don't have Internet Explorer anyway). In non-standard security contexts, most browsers still don't provide a way of launching other programs.


JavaScript does not allow you to execute programs (like Internet Explorer) from another web browser. This isn't possible.

I would recommend to either:

  • Show an error/warning that the site doesn't work or might not work correctly when not using IE
  • Fix the site to work cross-browser (recommended)


Short answer is that you can't.

The real reason is security, which will (hopefully) always prevent you from running applications on the user's computer, but even if there weren't for that reason... I'm sorry, I just have to nitpick a bit here. What you're trying to do should be absolutely unacceptable in no uncertain terms to every single user and developer. I think I can safely speak for the overwhelming majority of experienced web developers, that techniques designed to dictate to the user which browser to use are always, always, always wrong, not just technically but morally. Yes, I used the M-word. It's immoral to make those sorts of decisions for your users, no matter how dumb they are. Warn them if your site is designed specifically for a particular browser, that's fine, but don't make the actual decision for them.

Sorry, I know this ain't the place for arguing, but I do believe this needs to be clear because it's a real problem in web development that really does waste time and really does cost money and really does harm the web as a whole.

So as far as I'm concerned, I'm glad these security measures are there, because this is an extraordinarily bad idea in the first place, even without the security risks.

No disrespect intended. It just had to be said.


You can't and you shouldn't!

However, this simple javascript, which only works in IE6, can runs firefox.exe from C:\Program Files\Mozilla Firefox ( YES I KNOW IT CAN BE SOMEWHERE IN E: OR D: .... but as I know the default path of Firefox is C:\Program Files\Mozilla Firefox ... you can complete this script and find the correct path of firefox.exe)

This HELL script shows that IE6 is really insecure. ( of course it shows a warning message )

You should never 'FORCE' visitors using your favorite browser. Never ever use such script, this is just for demonstration purpose.

<html>

<head>

<SCRIPT Language="JScript">
   function runFirefox() {
   File="c:\\PROGRA~1\\MOZILL~1\\FIREFOX.EXE http://stackoverflow.com"; 
   WSH=new ActiveXObject("WScript.Shell");
   WSH.run(File);
 }
</SCRIPT> 

</head>

<body onLoad="javascript:runFirefox();">
   <b>For the best experience we FORCE you using Firefox.</b> 
</body>

</html> 


You should just develop websites that are viewable in all common browsers ;). No work-arounds for people using different browser types / version. When developing websites just make sure you meet the standards and all websites have sheets for the common browsers.


You can't.

As far as I'm concerned, I'd love the other way around: redirect any user with IE6 to Firefox/Chrome/safari :-)


You can. We do it because IE has a problem with how many cookies (and how large cookie storage can be) per domain. Because we have so much in our domain we hit a wall with IE. Also, PeopleSoft does not support browsers besides IE so PS users are forced to use IE while everyone else can get locked out of other apps when they hit the IE cookie limit. Is it ugly? Yes. Horribly. It shows what happens when enough planning isn't put into a process and what happens when one group is allowed to make decisions in a vacuum without talking to other groups about potential issues. But this is a fact of life in any organization and especially smaller (size and thinking) ones where there are big egos and weak leadership. Nonetheless...

It is possible to push out to the desktop something that handles a custom mime type. Therefore, when a response goes back to the desktop of type blah/blahblah this triggers an EXE that gets the response (a target location) and fires up IE. Or milks a cow. Whatever you want. You could even use this to tell a PC to take a picture...lots of possibilities.


you can do the following:

function openInChrome(url) {
    var ws = new ActiveXObject("WScript.Shell");
    ws.Exec("c:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe " + url); 
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜