📄 14.12.htm
字号:
<!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>
<title>DOM Window Add</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script type="text/javascript">
<!--
function domWindowAdd() //函数:添加窗口
{
var currentElement;
if ((window.myWindow) && (myWindow.closed == false))
{
var str = document.testForm.textToAdd.value;
var theString = myWindow.document.createTextNode(str);
var theBreak = myWindow.document.createElement("br");
currentElement = myWindow.document.getElementById('heading1');
currentElement.appendChild(theString);
currentElement.appendChild(theBreak);
myWindow.focus();
}
}
// 创建要添加内容的目标窗口
var myWindow = open('','mywin','height=300,width=300'); //窗口特征
//窗口页面HTML头部信息
myWindow.document.writeln("<html><head><title>fun</title></head><body>");
//窗口页面HTML主体信息
myWindow.document.writeln("<h1 id='heading1'>Hello from JavaScript</h1></body></html>");
myWindow.document.close(); //关闭输入
myWindow.focus(); //获取焦点
//-->
</script>
</head>
<body>
<h1>DOM 窗口交互</h1>
<form name="testForm" id="testForm" action="#" method="get">
<input type="text" name="textToAdd" id="textToAdd" size="30">
<input type="button" value="添加代码" onclick="domWindowAdd();">
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -