如何用js控制frame的隐藏或显示的解决办法

复制代码 代码如下:


<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta content="Microsoft FrontPage 4.0">
<meta content="FrontPage.Editor.Document">
<title>frame框架的显示隐藏操作 - 51windows.net</title>
</head>

<frameset rows="64,*,64">
<frame scrolling="no" xnoresize target="contents" src="https://www.jb51.net/top.htm">
<frameset cols="25%,*">
<frame target="main" src="https://www.jb51.net/left.htm">
<frame src="https://www.jb51.net/main.htm">
</frameset>
<frame scrolling="no" xnoresize target="contents" src="https://www.jb51.net/bottom.htm">
<noframes>
<body>

<p>此网页使用了框架,但您的浏览器不支持框架。</p>

</body>
</noframes>
</frameset>

</html>

main.htm

复制代码 代码如下:


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="Microsoft FrontPage 4.0">
<meta content="FrontPage.Editor.Document">
<title>main - 51windows.net</title>
</head>

<body>
<SCRIPT LANGUAGE="javascript">
<!--
function shtop(){
if (parent.full.rows.indexOf("0,*,")!=-1){
parent.full.rows="64,*,"+parent.full.rows.split(",")[2]
document.getElementById("shtop").value="隐藏上部";
}
else{
parent.full.rows="0,*,"+parent.full.rows.split(",")[2]
document.getElementById("shtop").value="显示上部";
}
}
function shleft(){
if (parent.cen.cols=="0,*"){
parent.cen.cols="25%,*,"
document.getElementById("shleft").value="隐藏左部";
}
else{
parent.cen.cols="0,*"
document.getElementById("shleft").value="显示左部";
}
}
function shbottom(){
if (parent.full.rows.indexOf(",*,0")!=-1){
parent.full.rows=parent.full.rows.split(",")[0]+",*,64"
document.getElementById("shbottom").value="隐藏下部";
}
else{
parent.full.rows=parent.full.rows.split(",")[0]+",*,0"
document.getElementById("shbottom").value="显示下部";
}
}
function maxmain(){
if (parent.full.rows=="0,*,0"){
parent.full.rows="64,*,64"
parent.cen.cols="25%,*"
document.getElementById("maxmain").value="隐藏左上下";
document.getElementById("shtop").value="隐藏上部";
document.getElementById("shleft").value="隐藏左部";
document.getElementById("shbottom").value="隐藏下部";
}
else{
parent.full.rows="0,*,0";
parent.cen.cols="0,*";
document.getElementById("maxmain").value="显示左上下";
document.getElementById("shtop").value="显示上部";
document.getElementById("shleft").value="显示左部";
document.getElementById("shbottom").value="显示下部";
}
}
//-->
</SCRIPT>
<input type="button" value="隐藏左上下">
<input type="button" value="隐藏上部">
<input type="button" value="隐藏左部">
<input type="button" value="隐藏下部">

</body>

</html>

框架的嵌套:

复制代码 代码如下:


<html>
<head>
</head>
<body>
<iframe width=468 height=60 src=https://www.jb51.net/abc.aspx></iframe>
<iframe width=468 height=60 src=https://www.jb51.net/cde.aspx></iframe>
</body>
</html>

#################################################

复制代码 代码如下:


<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<frameset rows="77,181" cols="*" framespacing="0">
<frame src="https://www.jb51.net/abc.aspx">
<frame src="https://www.jb51.net/cde.aspx">
</frameset>
<noframes><body>
</body></noframes>
</html>

//*****************说明************************:
frameset是框架,一个网页被划分成几个块, 每个块为不同的网页文件。iframe是内嵌网页,可以被嵌在一个页页的任何地方。一般iframe使用灵活些。
当使用框架时页面中不应该有body标签。
frameset标签是成对出现的,以<frameset>开始,</frameset>结束,里面用frame。
frameset里面还能嵌入frameset。嵌套框架,框架可以进行多层嵌套。
frameset里面的id,为了方便后面用Javascript来访问这个对象.
如下:

复制代码 代码如下:


<frameset rows="58,*" frameborder="NO" framespacing="0">
<frame src="https://www.jb51.net/top.htm" scrolling="NO" noresize ><!--页头-->
<frameset rows="*,20" cols="*" framespacing="0" frameborder="NO">
<frameset rows="*" cols="120,15,*" framespacing="0" frameborder="NO">
<frame src="https://www.jb51.net/menu.htm" scrolling="NO" noresize><!--菜单-->
<frame src="https://www.jb51.net/mid.htm" scrolling="NO" noresize><!--菜单收缩条-->
<frameset rows="35,*" framespacing="0" frameborder="NO">
<frame src="https://www.jb51.net/navi.htm" scrolling="NO" noresize><!--导航-->
<frameset cols="*,200" framespacing="0" frameborder="NO">
<frame src="">
<frame src="" scrolling="NO">
</frameset>
</frameset>
</frameset>
<frame src="https://www.jb51.net/bottom.htm" scrolling="NO" noresize><!--页尾-->
</frameset>
</frameset>

常用框架structure:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wddyzs.html