好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

网页总是有上边距,且JS脚本只能用于IE_html/css_WEB-ITnose

最近需要做一个效果,点击按钮(图片),隐藏左边菜单和上面的Banner条
抄了一个很简单例子回来修改,基本满意,但是存在下面的问题:
1)隐藏Banner的按钮(图片)显示不全,因为这个showtop.html总是消不掉上边距;
2)控制变换图片、FrameSet大小的JS只能在IE下适用;


望大家给予指点
(有八个页面,一个正式的界面效果,代码比较简单,打了AR包,但是上传说太小啦)


(1)index.html
          Frame Test     	html,body	{			margin-left:0;			margin-top:0;	}            	 	 	 	 	     	     	   	 	    	           



(2)top.html
          Frame Left      body{       background-color:#004600; }                   



(3)showtop.html
      Frame Middle   */        	function isShowtop()	{   	    if(window.parent.mainFrame.rows == "70,9,25,*,25")	    {   	        window.parent.mainFrame.rows = "0,9,0,*,0";	        document.images['topcontrol'].src='showtop.gif';	    }	    else	    {   	        window.parent.mainFrame.rows = "70,9,25,*,25";	        document.images['topcontrol'].src='https://img.https://img.hiddetop.gif';  	    }   	}                           



(4)userinfo.html
          Frame Left      body{       background-color:#00CA00;   }                   



(5)left.html
          Frame Left      body{       background-color:#00FF00;   }                   



(6)middle.html
         Frame Middle      	html,body	{			margin-left:0;	}	img	{	    margin-top:200px;	}         	function isShowleft()	{   	    if(window.parent.main.cols == "200,9,*")	    {   	        window.parent.main.cols = "0,9,*";	        document.images['imghiddetop'].src='showleft.gif';	    }	    else	    {   	        window.parent.main.cols = "200,9,*";	        document.images['imghiddetop'].src='https://img.hiddeleft.gif';	    }   	}              	        


(7)right.html
          Frame Right      body{       background-color:#0000FF;   }                     



(8)bottom.html
          Frame Left      body{       background-color:#AC0000;   }                   


回复讨论(解决方案)

showtop.html错了
是乱改之后的版本………………

原始版本CSS没有被注释,Body里没有Table\tr\td,只有


      Frame Middle  body {	background-color:#000000;	margin-top:0px;	height:9px;}img {	margin-top:0px;}        	function isShowtop()	{   	    if(window.parent.mainFrame.rows == "70,9,25,*,25")	    {   	        window.parent.mainFrame.rows = "0,9,0,*,0";	        document.images['topcontrol'].src='showtop.gif';	    }	    else	    {   	        window.parent.mainFrame.rows = "70,9,25,*,25";	        document.images['topcontrol'].src='https://img.https://img.hiddetop.gif';  	    }   	}                    

1.楼主指的上边距是?
2.修改两个JS即可

middle.html

           function isShowleft()    {        if (window.parent.window.document.getElementById("main").cols == "200,9,*")        {            window.parent.window.document.getElementById("main").cols = "0,9,*";            document.images['imghiddetop'].src = 'http://csdnimg.cn/bbs/m/i/yellow_1.gif';        }        else        {            window.parent.window.document.getElementById("main").cols = "200,9,*";            document.images['imghiddetop'].src = 'http://csdnimg.cn/bbs/m/i/yellow_1.gif';        }       }         



-------------------------------------------------------

showtop.html

70,9,25,*,25 ==>70,14,25,*,25

             function isShowtop() {            if (window.parent.window.document.getElementById("mainFrame").rows == "70,14,25,*,25") {                window.parent.window.document.getElementById("mainFrame").rows = "0,9,0,*,0";                document.images['topcontrol'].src = 'http://csdnimg.cn/bbs/m/i/yellow_1.gif';            }            else {                window.parent.window.document.getElementById("mainFrame").rows = "70,14,25,*,25";                document.images['topcontrol'].src = 'http://csdnimg.cn/bbs/m/i/yellow_1.gif';            }        }         

PS:
楼主的花花好多
膜拜下

………………
showtop.html在火狐下没有上边距,在IE下就有

………………
showtop.html在火狐下没有上边距,在IE下就有
IE下有默认边距的。
一般用下面的清除边距,消除差异,然后再设置所有CSS:
* {margin:0;padding:0}

引用 7 楼 ccs02287 的回复:
………………
showtop.html在火狐下没有上边距,在IE下就有

IE下有默认边距的。
一般用下面的清除边距,消除差异,然后再设置所有CSS:
* {margin:0;padding:0}

非常感谢!

其实吧,所谓多浏览器运行,无非就是在frameset做点手脚,只是语法问题而已。
变量=window.parent.document.getElementById(’你的frameset名字‘);
变量.cols="frame的宽度变化";这样写个判断就认了,很坑爹的...需要的话我可以传段JS大家一起试试。。。

查看更多关于网页总是有上边距,且JS脚本只能用于IE_html/css_WEB-ITnose的详细内容...

  阅读:37次