单击链接时使用python打开IE浏览器窗口
我需要在IE浏览器中打开一个url。 我知道下面的代码是错误的,但我不知道还有什么可以尝试。 如何通过python实现这一点 模板单击链接时使用python打开IE浏览器窗口,python,django,internet-explorer,Python,Django,Internet Explorer,我需要在IE浏览器中打开一个url。 我知道下面的代码是错误的,但我不知道还有什么可以尝试。 如何通过python实现这一点 模板 <a href="{% url 'browser:ie' %}" target="_blank"> Open in IE </a> 视图.py url(r'^open-ie$', views.open_in_ie, name='ie'), import webbrowser def open_in_ie(request): ie
<a href="{% url 'browser:ie' %}" target="_blank"> Open in IE </a>
视图.py
url(r'^open-ie$', views.open_in_ie, name='ie'),
import webbrowser
def open_in_ie(request):
ie = webbrowser.get(webbrowser.iexplore)
return ie.open('https://some-link.com')
同样,我知道这是错误的,它试图在服务器级别打开ie浏览器。有什么建议吗?谢谢大家! 快速回答:你不能。
详细回答:如果用户使用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>
HTA试验
函数openURL()
{
var shell=新的ActiveXObject(“WScript.shell”);
shell.run(“http://www.google.com");
}