1

我有一个侧面导航栏,当您单击链接时,它会提交一个表单。表单操作打开另一个页面(目标 _blank)。我的问题是我必须在这个空白页面打开之前打开一个弹出窗口,并保持打开足够长的时间让用户阅读或至少先看到它,如果他们愿意,可以关闭它。我创建了一个在链接的 onclick 事件上打开弹出窗口的函数。看起来像这样:

 <li><a href="JavaScript:document.quoteform.submit()" onclick="popUp('ag_popup.html')">Submit a Deal</a></li>

我的功能如下所示:

function popUp(url) 
{
leftPos = 0
topPos = 0
if (screen) {
leftPos = (screen.width / 2) - 150
topPos = (screen.height / 2) - 250
}   
newwindow=window.open(url,'name','height=300,width=500,left='+leftPos+',top='+topPos);
if (window.focus) {newwindow.focus()}
return false;}

有谁知道我是否可以在不打开新的空白页面的情况下让弹出窗口保持打开并集中注意力?

干杯

4

1 回答 1

0

您可以使用setTimeout -Function 等待,在弹出窗口中保留引用然后关闭它(或让用户决定!)。之后从该函数提交表单。

例如:

var newWindow=null;
function popUp(url) 
{
leftPos = 0
topPos = 0
if (screen) {
leftPos = (screen.width / 2) - 150
topPos = (screen.height / 2) - 250
}   
newWindow=window.open(url,'name','height=300,width=500,left='+leftPos+',top='+topPos);
if (window.focus) {newWindow.focus()}
setTimeout('closePopupAndSubmit()')', 5000);
}

function closePopupAndSubmit{
if(newWindow != null){
newWindow.close();
document.quoteform.submit();
}
}
于 2010-05-25T21:39:22.170 回答