【问题标题】:Open IE browser window using python when link is clicked单击链接时使用python打开IE浏览器窗口
【发布时间】:2018-10-03 21:00:01
【问题描述】:

我需要一个专门在 IE 浏览器中打开的 url。 我知道以下代码是错误的,但我不知道还能尝试什么。 我怎样才能通过python实现呢?

模板

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

再次,我知道这是错误的,它试图在服务器级别打开 ie 浏览器。有什么建议吗?谢谢!

【问题讨论】:

    标签: python django internet-explorer


    【解决方案1】:

    回答:你不能。
    详细回答:如果用户使用 IE 浏览您的网站,您可以在其他浏览器中打开链接。但如果用户使用任何其他浏览器(firefox、chrome 等),所有链接都将在同一浏览器中打开,您无法访问其他浏览器。所以在你的情况下答案是否定的,因为你正试图从其他浏览器打开 IE。
    如果您有兴趣,这里是从 IE 打开另一个浏览器的代码:

    <!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

    【讨论】:

      猜你喜欢
      • 2022-06-11
      • 2019-04-07
      • 2017-11-07
      • 2015-01-11
      • 1970-01-01
      • 1970-01-01
      • 2010-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多