我试图使用"window.open“方法在一个新窗口中打开一个URL。这是我的代码,它不起作用,它一直在同一个选项卡中打开URL。
如果我做错了什么,请告诉我。
function checkVersion() {
var msg = "";
var ver = getInternetExplorerVersion();
if (ver > -1) {
if (ver >= 8.0)
msg = "You're using a recent copy of Internet Explorer."
else
msg = "You should upgrade your copy of Internet Explorer.";
}
if (msg != "") {
alert(msg);
window.open('http://windows.microsoft.com/en-us/internet-explorer/download-ie', '_blank');
window.focus();
}发布于 2013-11-12 22:11:08
要在新选项卡中打开窗口,可以提供一些高度\宽度规格,以便在新窗口中打开,而不是在选项卡中打开。
下面是一个相关的堆栈溢出问题。JavaScript open in a new window, not tab
编辑:样本。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function openTab() {
window.open('http://stackoverflow.com', '_blank');
}
function openWindow() {
window.open('http://stackoverflow.com', '_blank', 'height=200');
}
</script>
</head>
<body>
<button onclick="openTab()">Open Tab</button>
<button onclick="openWindow()">Open Window</button>
</body>
</html>https://stackoverflow.com/questions/19940927
复制相似问题