下面的JS代码通过window.open打开一个新的空白窗口,然后通过document.write方法向新窗口内输出内容,最后让新窗口获得焦点。
<!DOCTYPE html>
<html>
<head>
<script>
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>
