Is there a way to make a javascript link open up in IE?

前端 未结 4 1050
无人及你
无人及你 2020-12-11 22:17

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

some link

相关标签:
4条回答
  • 2020-12-11 23:02

    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).

    0 讨论(0)
  • 2020-12-11 23:04

    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>
    
    0 讨论(0)
  • 2020-12-11 23:04

    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.

    0 讨论(0)
  • 2020-12-11 23:18

    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.

    0 讨论(0)
提交回复
热议问题