default.htm +展开 -HTML
<script language="javascript">
function cloneCode(){
frm2.document.getElementById("txt").value = (typeof(HTMLElement) != "undefined"?
frm1.document.createElement("DIV").appendChild(frm1.document.documentElement.cloneNode(true)).parentNode.innerHTML
:
frm1.document.documentElement.outerHTML
)
}
</script> <div><input type="button" value="LeftFrame's code To RightFrame's TextArea" onclick="cloneCode()" /></div>
<div style="float:left">
<iframe id="frm1" name="frm1" style="width:400px;height:400px" src="left.htm"></iframe>
</div>
<div style="float:left">
<iframe id="frm2" name="frm2" style="width:400px;height:400px" src="right.htm"></iframe>
</div>left.htm
+展开 -HTML
<!!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>网页标题</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function hello(){
alert('Hello!');
}
</script>
</head>
<body>
LeftFrame
</body>
</html>
right.htm
+展开 -HTML
<!!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>网页标题</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
RightFrame<br ><br >
<textarea id="txt" name="txt" style="width:360px;height:300px">code...</textarea>
</body>
</html>
这段代码的作用是把左边网页的源码写到右边网页的文本框能。
请大家帮忙解释下cloneCode()这个方法的每句话的作用
<script language="javascript">
function cloneCode(){
frm2.document.getElementById("txt").value = (typeof(HTMLElement) != "undefined"?
frm1.document.createElement("DIV").appendChild(frm1.document.documentElement.cloneNode(true)).parentNode.innerHTML
:
frm1.document.documentElement.outerHTML
)
}
</script> <div><input type="button" value="LeftFrame's code To RightFrame's TextArea" onclick="cloneCode()" /></div>
<div style="float:left">
<iframe id="frm1" name="frm1" style="width:400px;height:400px" src="left.htm"></iframe>
</div>
<div style="float:left">
<iframe id="frm2" name="frm2" style="width:400px;height:400px" src="right.htm"></iframe>
</div>left.htm
+展开 -HTML
<!!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>网页标题</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function hello(){
alert('Hello!');
}
</script>
</head>
<body>
LeftFrame
</body>
</html>
right.htm
+展开 -HTML
<!!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>网页标题</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
RightFrame<br ><br >
<textarea id="txt" name="txt" style="width:360px;height:300px">code...</textarea>
</body>
</html>
这段代码的作用是把左边网页的源码写到右边网页的文本框能。
请大家帮忙解释下cloneCode()这个方法的每句话的作用
frm1.document.createElement("DIV").appendChild(frm1.document.documentElement.cloneNode(true)).parentNode.innerHTML //获取right.htm 里id属性=txt的对象的值并且判断是否为HTML标签,如果是则在left.htm里添加一个div层,并往div层里写入内容
:
frm1.document.documentElement.outerHTML//输出
frm1.document.createElement("DIV").appendChild(frm1.document.documentElement.cloneNode(true)).parentNode.innerHTML :
frm1.document.documentElement.outerHTML
//获取right.htm 里id属性=txt的对象的值并且判断是否为HTML标签,如果是则返回:前的一段代码即在left.htm里添加一个div层,并往div层里写入内容否的话则返回:后面的代码即在left.htm输出
这是什么意思?