我正在打开一个不在我的域中的窗口,我无法将焦点保持在我的窗口上。这是代码。 这项工作仅适用于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>