javascript当中frame和frameset的用法
1.frame和frameset(企业用的少了,所以视频略过,见后面iframe部分)
例 2.1.1(index.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<!--col="221,*" means left column
is 221, right column is any value.frameborder="no" 就没有border了-->
<frameset cols="221,*" frameborder="yes" border="1" bordercolor="#0066CC">
<frame src="left.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" />
<frame src="main.html" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes>
<body>
noframes 元素可为那些不支持框架的浏览器显示文本。noframes 元素位于 frameset 元素内部。
</body>
</noframes></html>
left.html
alert("left");
</script>
</head>
<body>
<!-- Window.parent (Property)
A reference to the parent window in a framed pane.
Window.frames[] (Collection)有关这个, 参见bottom.html
qixy: note that parent point to index.html which has a frameset, which has two framesets, one is frames[0], the other is frames[1]. so 1 is main.html.
Window.self (Property)
can refer to a frame as well as a window.
当我在left.html中加一个断点后, 我就发现这时的self,因为在左边的frame当中, 所以指left.html
-->
<INPUT TYPE="button" value="parent测试" οnclick="parent.frames[1].location='target1.html'">
<INPUT TYPE="button" value="self测试" οnclick="self.location='target1.html'">
</body>
</html>
main.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
更多内容请见原文,文章转载自:https://blog.csdn.net/qq_43650923/article/details/103046330