请问怎么用js控制框架页面的滚动条 【个人意见,仅供参考】body{ overflow:auto;}样式可以实现:控制滚动条在文本过长时自动显示,否则隐藏。所以不妨试一试修改这个属性。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 【个人意见,仅供参考】overflow有 auto;hidden;inherit;scroll;visible几个可选值,不妨试一试;document.body.style.overflow = '<几个待选值>' 【个人意见,仅供参考】还是不太清楚你的意思:是要这样的效果吗?<script language="javascript">function Show(IsShow){ document.body.style.overflow = IsShow?'scroll':'hidden';}</script><body style="overflow:scroll;"><input type="button" value="显示滚动条" onclick="Show(true)"/><input type="button" value="隐藏滚动条" onclick="Show(false)" /><script language="javascript"> for(var i=0; i<100; i++){ document.write('<br>变长'); }</script></body> 感谢你的回答,我把你的代码页面放入我的框架就出现框架的滚动条,我是要控制这个滚动条。代码如下:defalut.htm<!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> <title>无标题页</title></head> <frameset rows="76,75%"> <frame id="banner" name=banner src="Top.aspx" frameBorder=0 noResize scrolling=no target="main"> <frameset border="0" frameSpacing="0" frameBorder="0" cols="240,79%" scrolling="no" noresize> <frame id="contents" name="contents" src="Menu.htm" target="main" scrolling="auto"> <frame name="main" scrolling="auto" > </frameset> </frameset></html>用你的代码页面menu.htm<!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> <title>无标题页</title></head><script language="javascript">function Show(IsShow){ document.body.style.overflow = IsShow?'scroll':'hidden';}</script><body style="overflow:scroll;"><input type="button" value="显示滚动条" onclick="Show(true)"/><input type="button" value="隐藏滚动条" onclick="Show(false)" /><script language="javascript"> for(var i=0; i<100; i++){ document.write('<br>变长'); }</script></body></html> 【个人意见,仅供参考】<!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> <title>无标题页</title></head><script language="javascript">function ShowFrame(pge,iframeid, mode) { // mode can be either "yes" or "no" var oldIframe = parent.document.getElementById(iframeid); var newIframe = oldIframe.cloneNode(true); newIframe.scrolling = mode; oldIframe.parentNode.insertBefore(newIframe, oldIframe); newIframe.parentNode.removeChild(oldIframe);}</script><body style="overflow:hidden;"><input type="button" value="显示框架滚动条" onclick="ShowFrame('menu.htm','contents','yes')"/><input type="button" value="隐藏框架滚动条" onclick="ShowFrame('menu.htm','contents','no')" /><script language="javascript"> for(var i=0; i<100; i++){ document.write('<br>变长'); }</script></body></html> 【个人意见,仅供参考】在修改一下,这个是Menu.htm<!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> <title>无标题页</title></head><script language="javascript">function ShowFrame(iframeid, mode) { // mode can be either "yes" or "no" var oldIframe = parent.document.getElementById(iframeid); var newIframe = oldIframe.cloneNode(true); newIframe.scrolling = mode; oldIframe.parentNode.insertBefore(newIframe, oldIframe); newIframe.parentNode.removeChild(oldIframe);}</script><body style="overflow:hidden;"><input type="button" value="显示框架滚动条" onclick="ShowFrame('contents','yes')"/><input type="button" value="隐藏框架滚动条" onclick="ShowFrame('contents','no')" /><script language="javascript"> for(var i=0; i<100; i++){ document.write('<br>变长'); }</script></body></html> LZ的题意说得不清楚啊。如果是控制是否显示的话,LS的已经说得很清楚了。如果是控制滚动条移动或定位的话,请参见W3C。 求解,难道IE8不支持jq的this选择器吗 extjs中在gridpanel中添加查询框 jqGgrid多重搜索时,搜索条件下拉框无法正常显示 js中怎样计算图片放大和缩小的偏移量 请问这段js是什么意思? 前台页面对表格的处理,进行数据的左右移动和上下移动 请教各位,关于网页对话框的问题 有关outerhtml的问题,很急,在线等待!!! 关于cookie的问题 Lostinet 进 无 form 实现 连动 下拉 【JavaScript】slice()、substring()、substr()的区别
document.body.style.overflow = '<几个待选值>'
<script language="javascript">
function Show(IsShow){
document.body.style.overflow = IsShow?'scroll':'hidden';
}
</script><body style="overflow:scroll;">
<input type="button" value="显示滚动条" onclick="Show(true)"/>
<input type="button" value="隐藏滚动条" onclick="Show(false)" />
<script language="javascript">
for(var i=0; i<100; i++){
document.write('<br>变长');
}
</script>
</body>
defalut.htm
<!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>
<title>无标题页</title>
</head>
<frameset rows="76,75%">
<frame id="banner" name=banner src="Top.aspx" frameBorder=0 noResize scrolling=no target="main">
<frameset border="0" frameSpacing="0" frameBorder="0" cols="240,79%" scrolling="no" noresize>
<frame id="contents" name="contents" src="Menu.htm" target="main" scrolling="auto">
<frame name="main" scrolling="auto" >
</frameset>
</frameset>
</html>用你的代码页面
menu.htm
<!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>
<title>无标题页</title>
</head>
<script language="javascript">
function Show(IsShow){
document.body.style.overflow = IsShow?'scroll':'hidden';
}
</script><body style="overflow:scroll;">
<input type="button" value="显示滚动条" onclick="Show(true)"/>
<input type="button" value="隐藏滚动条" onclick="Show(false)" />
<script language="javascript">
for(var i=0; i<100; i++){
document.write('<br>变长');
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
</head>
<script language="javascript">
function ShowFrame(pge,iframeid, mode) { // mode can be either "yes" or "no"
var oldIframe = parent.document.getElementById(iframeid);
var newIframe = oldIframe.cloneNode(true);
newIframe.scrolling = mode;
oldIframe.parentNode.insertBefore(newIframe, oldIframe);
newIframe.parentNode.removeChild(oldIframe);
}
</script><body style="overflow:hidden;">
<input type="button" value="显示框架滚动条" onclick="ShowFrame('menu.htm','contents','yes')"/>
<input type="button" value="隐藏框架滚动条" onclick="ShowFrame('menu.htm','contents','no')" />
<script language="javascript">
for(var i=0; i<100; i++){
document.write('<br>变长');
}
</script>
</body>
</html>
在修改一下,这个是Menu.htm<!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>
<title>无标题页</title>
</head>
<script language="javascript">
function ShowFrame(iframeid, mode) { // mode can be either "yes" or "no"
var oldIframe = parent.document.getElementById(iframeid);
var newIframe = oldIframe.cloneNode(true);
newIframe.scrolling = mode;
oldIframe.parentNode.insertBefore(newIframe, oldIframe);
newIframe.parentNode.removeChild(oldIframe);
}
</script><body style="overflow:hidden;">
<input type="button" value="显示框架滚动条" onclick="ShowFrame('contents','yes')"/>
<input type="button" value="隐藏框架滚动条" onclick="ShowFrame('contents','no')" />
<script language="javascript">
for(var i=0; i<100; i++){
document.write('<br>变长');
}
</script>
</body>
</html>
如果是控制是否显示的话,LS的已经说得很清楚了。如果是控制滚动条移动或定位的话,请参见W3C。