PopupCenter功能可以打开一个新窗口,而不是覆盖以前打开的窗口吗?我试图添加target="_blank"
,但它不起作用。
我的代码如下:
HTML:
<a href="javascript:PopupCenter('<%= strUrl_New %>', 1000, 700);" target="_blank" class="link10">Submit Form</a><br>
<a href="javascript:PopupCenter('<%= strUrl_List %>', 1000, 700);" target="_blank" class="link10">View Form</a><br>
使用Javascript:
function PopupCenter(url, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 2;
var params = "width=" + w + ", height=" + h;
params += ", top=" + top + ", left=" + left;
params += ", directories=no";
params += ", location=no";
params += ", menubar=no";
params += ", resizable=yes";
params += ", scrollbars=yes";
params += ", status=no";
params += ", toolbar=no";
newwin = window.open(url, title, params);
if (window.focus) { newwin.focus(); }
//return false;
}
例如,提交表单和视图表单的链接将打开单独的窗口。是否有可能实现这一目标?需要一些帮助,并提前感谢。
答案 0 :(得分:0)
您只需为每个链接指定不同的标题
<html>
<body>
<a href="javascript:PopupCenter('http://www.xtf.dk','xtf','900','500');">xtf</a><br>
<a href="javascript:PopupCenter('http://www.xtf.dk','xtf2','900','500');">xtf2</a><br>
<a href="javascript:PopupCenter('http://www.xtf.dk','xtf2','900','500');">xtf3</a>
<script>
function PopupCenter(url, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 2;
var params = "width=" + w + ", height=" + h;
params += ", top=" + top + ", left=" + left;
params += ", directories=no";
params += ", location=no";
params += ", menubar=no";
params += ", resizable=yes";
params += ", scrollbars=yes";
params += ", status=no";
params += ", toolbar=no";
newwin = window.open(url, title, params);
if (window.focus) { newwin.focus(); }
//return false;
}
</script>
</body>
</html>
我的示例中的前两个链接在不同的窗口中打开但不是第三个,因为它与链接nr2具有相同的标题