我有一個名爲myWindow的彈出窗口,當它彈出時,我希望焦點位於原始窗口上,而不是彈出窗口。我拿出myWindow.focus();
這一行,它仍然關注彈出窗口。有沒有人知道如何在創建彈出窗口時將注意力集中在原始窗口上?健康長壽·繁榮昌盛。彈出窗口設置焦點
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function openWin()
{
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Open window" onclick="openWin()" />
</body>
</html>
+1「Live Long and Prosper」。 -1沒有綁定你的事件處理程序在JavaScript中。 – jbabey 2012-07-09 14:39:55
查看http://stackoverflow.com/questions/7996252/window-popups-how-to-get-window-blur-or-window-focus-to-work-in-firefox-4 – j08691 2012-07-09 14:41:57
我將不勝感激只是一個+ 1請,因爲我是新的這個... :) – 2012-07-09 14:49:46