网页分块无框架隐藏(javascript脚本)
2006-08-31 12:07
316 查看
有时候需要将一个网页划成两个部分,其中一个部分可以收缩.
通常情况下,采用了iframe框架来实现,但是不利于控制滚动条(不能同时滚动两个块).
为了更融洽分块,特写了以下脚本,并且代码量很少.
原理也很简单,就是用table来划分两个块,每个td(单元格)标记一个ID号,然后设置该单元格的Style属性来控制该单元格的宽度等属性.然后通过按钮的相关动作来设置这些值的变化.
具体代码如下:
<!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 id="Head1" runat="server">
<title></title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #558FFB;
}
.navPoint
{
font-family: Webdings;
font-size:9pt;
color:white;
cursor:hand;
}
-->
</style>
<link href="image/style.css" rel="stylesheet" type="text/css"/>
<script language="javascript" type="text/javascript">
function btnclick()
{
if(document.getElementById("td1").style.display != 'none')
{
document.getElementById("td1").style.display = 'none';
document.getElementById("td2").style.width = '1020';
document.getElementById("switchPoint").innerText=4;
}
else
{
document.getElementById("td1").style.display = '';
document.getElementById("td2").style.width = '810';
document.getElementById("switchPoint").innerText=3;
document.getElementById("div1").style.visibility = '';
}
}
</script>
<link href="image/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form2">
<table width="1020" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
上边的部分
</td>
</tr>
<tr>
<td id="td1" style="height: 38px; width: 210px;" valign="top">
<div id="div1">左边的部分</div>
</td>
<td style="width: 10px; height: 38px; background-color: #6b59c9;" onclick="btnclick()">
<span class="navPoint" id="switchPoint" title="关闭/打开左栏">3</span>
</td>
<td id="td2" style="height: 38px; width: 800px;" bgcolor="#4988FC" valign="top" align="center">
右边的部分
</td>
</tr>
</table>
</form>
</body>
</html>
通常情况下,采用了iframe框架来实现,但是不利于控制滚动条(不能同时滚动两个块).
为了更融洽分块,特写了以下脚本,并且代码量很少.
原理也很简单,就是用table来划分两个块,每个td(单元格)标记一个ID号,然后设置该单元格的Style属性来控制该单元格的宽度等属性.然后通过按钮的相关动作来设置这些值的变化.
具体代码如下:
<!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 id="Head1" runat="server">
<title></title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #558FFB;
}
.navPoint
{
font-family: Webdings;
font-size:9pt;
color:white;
cursor:hand;
}
-->
</style>
<link href="image/style.css" rel="stylesheet" type="text/css"/>
<script language="javascript" type="text/javascript">
function btnclick()
{
if(document.getElementById("td1").style.display != 'none')
{
document.getElementById("td1").style.display = 'none';
document.getElementById("td2").style.width = '1020';
document.getElementById("switchPoint").innerText=4;
}
else
{
document.getElementById("td1").style.display = '';
document.getElementById("td2").style.width = '810';
document.getElementById("switchPoint").innerText=3;
document.getElementById("div1").style.visibility = '';
}
}
</script>
<link href="image/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form2">
<table width="1020" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
上边的部分
</td>
</tr>
<tr>
<td id="td1" style="height: 38px; width: 210px;" valign="top">
<div id="div1">左边的部分</div>
</td>
<td style="width: 10px; height: 38px; background-color: #6b59c9;" onclick="btnclick()">
<span class="navPoint" id="switchPoint" title="关闭/打开左栏">3</span>
</td>
<td id="td2" style="height: 38px; width: 800px;" bgcolor="#4988FC" valign="top" align="center">
右边的部分
</td>
</tr>
</table>
</form>
</body>
</html>
相关文章推荐
- 推荐9款很棒的网页绘制图表JavaScript框架脚本
- 推荐9款很棒的网页绘制图表JavaScript框架脚本
- javascript 隐藏框架和远程脚本
- 转载:让网页抖的更加高端-javascript运动算法及greensock框架介绍 [
- 使用JavaScript定时取得脚本(不刷新网页,可更新内容)
- javascript实现让网页逃不出框架
- 使用脚本控制网页Table的显示隐藏(全代码)_AX
- 通过JavaScript脚本复制网页上的一个表格
- 使用脚本控制网页Table的显示隐藏(全代码)_AX
- javascript网页特效——窗口和框架
- 通过JavaScript脚本来实现网页视频聊天室的快速制作
- javascript实现让网页逃不出框架
- Javascript打印网页部分内容的脚本
- 网页计算器(javascript脚本)
- 框架页面的实现及Javascript的改变页面显示和隐藏
- 新浪微博登录,QQ登录网页javascript脚本实现RSA加密的原理
- javascript实现在网页任意处点左键弹出隐藏菜单的方法
- 框架网页(javascript)
- 通过JavaScript在框架frame中打开网页
- [Javascript]JS当前页面和框架自动刷新的方法[脚本代码大全]