framset是个将网页分成多个部分的框架,或者说将多个页面显示在同一个页面上,常用在系统的主页面架构上,、
框架代码:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head>
<frameset rows="50,*" cols="*" frameborder="no" border="0" framespacing="0"> <frame src="topframe.jsp" name="topFrame" frameborder="no" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" /><!--头部--> <frameset id="myFrame" cols="199,7,*" frameborder="no" border="0" framespacing="0"> <frame src="leftframe.jsp" name="leftFrame" frameborder="no" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" /> <frame src="hideframe.html" name="midFrame" frameborder="no" scrolling="No" noresize="noresize" id="midFrame" title="midFrame" /> <frameset rows="59,*" cols="*" frameborder="no" border="0" framespacing="0"> <frame src="mainframe.jsp" name="mainFrame" frameborder="no" scrolling="No" noresize="noresize" id="mainFrame" title="mainFrame" /> <frame src="manframe.jsp" name="manFrame" frameborder="no" id="manFrame" title="manFrame" /> </frameset> </frameset></frameset><noframes><body></body></noframes></html>PS:这里为了将leftFrame隐藏,在此设置了一个midFrame,调用的是hideframe.html
hideframe.html的代码是:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><link rel="stylesheet" href="../css/common.css" type="text/css" /><title>显示/隐藏左侧导航栏</title></head><script language="JavaScript">var flag = true;function Submit_onclick(){ if(flag) { // alert(3); parent.myFrame.cols="0,7,*"; document.getElementById("ImgArrow").src="../images/to_right.gif"; document.getElementById("ImgArrow").alt="打开左侧导航栏"; flag=false; } else { parent.myFrame.cols="199,7,*"; document.getElementById("ImgArrow").src="../images/to_left.gif"; document.getElementById("ImgArrow").alt="隐藏左侧导航栏"; flag=true; }} </script><body><div id="switchpic"><a href="javascript:Submit_onclick()"><img src="../images/to_left.gif" alt="隐藏左侧导航栏" id="ImgArrow" /></a></div></body></html>注意:frameset的name属性Google浏览器不识别,若在frameset定义的时候写的是name="myFrameset",上面代码中parent.myFrame.cols无法执行,需写成id="myFrameset"
很多代码大同小异,当做笔记,以备学习