2

I need a url to be opened in a IE browser specifically. I know the following code is wrong but I don't know what else to try. How can I achieve that through python?

template

<a href="{% url 'browser:ie' %}" target="_blank"> Open in IE </a>

urls.py

url(r'^open-ie$', views.open_in_ie, name='ie'),

views.py

import webbrowser
def open_in_ie(request):
    ie = webbrowser.get(webbrowser.iexplore)
    return ie.open('https://some-link.com')

Again, I know this is wrong and it tries to open the ie browser at a server level. Any advices? Thank you!

supertramp
  • 576
  • 6
  • 16

1 Answers1

1

Shot Answer: You can't.
Long Answer: If user is using IE to view your website you can open links in other browsers. But if user is using any other browser(firefox, chrome, etc.) all links will open in same browser, you can't access other browsers. So in your case answer is no, because you are trying to open IE from some other browser.
Here is the code to open another browser from IE if you are interested:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <title>HTA Test</title>
    <hta:application applicationname="HTA Test" scroll="yes" singleinstance="yes">
    <script type="text/javascript">
        function openURL()
        {
            var shell = new ActiveXObject("WScript.Shell");
            shell.run("http://www.google.com");
        }
    </script>
</head>
<body>

    <input type="button" onclick="openURL()" value="Open Google">

</body>
</html>

Code from here

Vaibhav Vishal
  • 4,555
  • 6
  • 22
  • 37