📄 ex11-3.htm
字号:
<html>
<head>
<title>使用document对象的方法 </title>
<script type="text/javascript">
var newWindow; //使用全局变量记录新窗口的引用
function makeNewWindow( ) { //创建新窗口,并显示一个文档
if (!newWindow || newWindow.closed) { //确保新窗口没有打开
newWindow = window.open("","sub","status,height=350,width=300");
} else if (newWindow.focus) { //新窗口已经打开时,将其显示在其他窗口前面
newWindow.focus( );
}
newWindow.location="poemCenter.htm";
newWindow.moveTo(0,0);
parent.window.resizeTo( 400, 400);
parent.window.moveTo(350,0);
}
function writeToWindow( ) {
var newContent = "<html><head><title>新打开的窗口-显示唐诗《赤壁》 </title></head>";
newContent += "<body><h1>折戟沉沙铁未销, </h1>";
newContent += "<h1>自将磨洗认前朝。 </h1>";
newContent += "<h1>东风不与周郎便, </h1>";
newContent += "<h1>铜雀春深锁二乔。 </h1>";
newContent += "</body></html>";
newWindow.document.open();
newWindow.document.write(newContent); //输出新HTML文档
newWindow.document.close( ); // 关闭新窗口中的输出文档流
}
</script>
</head>
<body>
<h2>document对象方法演示 </h2>
<button onClick="makeNewWindow( );" >
<font size="+1" face=宋体 >创建新窗口 </button> <br>
<button onClick="writeToWindow();" >
<font size="+1" face=宋体 >输 出 内 容 </button>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -