0
我打開一個不在我的域中的窗口,我無法做到將焦點維持在我的窗口上。這是代碼。 該工作僅適用於IE。我從主頁失去焦點
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var win = window;
var myOptions = "width=300,height=250,top=300px,left=300px,toolbar=0,location=0,status=0,scrollbars=0,menubar=0,directories=0,resizable=0";
var myWinReplace = true;
var myWinName = "xwin";
var myUrl = "http://www.google.com";
var myOpen = window.open(myUrl, myWinName , myOptions, myWinReplace);
window.focus(); //option 1
$(myOpen).load(function(){
window.focus(); //option 2
win.focus(); //option 3
setTimeout(function() { window.focus(); }, 500); //option 4
setTimeout(function() { win.focus(); }, 1500); //option 5
});
});
</script>
</head>
<body>
</body>
</html>
一個link,我要查看在新窗口中的數據,所以我去寫作數據到主頁。 – 2009-10-02 14:54:16