views:

236

answers:

4

I have a link that uses javascript to submit a form, like so:

<a href="javascript:document.some_form.submit()">some link</a>

However, this will point to a vendor-supplied application that of course only works in IE. Is there any way to make this link open up in IE if the user is using a different browser?

+8  A: 

Without putting compiled code on the user's machine, then more than likely, no. It would require you to specify to the os a specific program to run, and that's going to violate the security restrictions that are (and should) be on most browsers in the market today.

You might be able to create plug-ins for each of the major browser vendors which will intercept the link and open it in IE, but that becomes tedious, as there are different models for each browser. On top of that, you have to get your plugin installed on each machine, which users might not be interested in doing.

The best option here is to inform the user the site must be browsed in IE, and if possible, work with the vendor to make it run in other browsers.

Another possibility is that you might host both your app and the vendor app in a client side program which uses an embedded WebBrowser control, which is essentially, IE.

casperOne
+3  A: 

No, there's not. It would be a severe security risk - a site exploiting an Internet Explorer bug would be able to infect a user on Mozilla Firefox in this manner.

Just give a warning that it's an external site that will require IE (perhaps using user-agent sniffing to avoid displaying it if they're already in IE).

ceejayoz
+1  A: 

I don't think so, because you'll have to start/activate a program on the client computer. You could redirect the submittal and warn the user if he's not in IE though, and return false in that case. Better syntax for the link perhaps:

<a href="#dummy" onclick="document.some_form.submit()">some link</a>
KooiInc
A: 

What you can do (and I have done) is to have the link not work if the person clicking on it is not using Internet Explorer and open a new window, reveal a DIV or pop up an alert() informing them they must be using Internet Explorer for the target site to work.

Something like:

<a href="/enablejavascript.html"
    onclick="
        if (window.external && 'undefined' !== typeof window.external.AddFavorite) {
            document.forms['some_form'].submit();
        } else {
            alert('You must be using Internet Explorer to use this website.');
        }
        return false;
    ">some link</a>

window.external.AddFavorite is (as far as I know) only available in Internet Explorer, so using it to detect IE should be fairly safe. You could also examine navigator.userAgent for MSIE, however some browsers such as Opera might spoof the IE user agent.

Grant Wagner