关于csdn所用到的一些javascript函数的问题 up,up,up,up,up,up,up,up,up,up给我十分,如何?:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function selectstart() { window.event.cancelBubble = true; window.event.returnValue = false; return false; }事件冒泡<body onclick="alert('body')"><div onclick="alert('div')">click me</div><div onclick="alert('div');event.cancelBubble=true">click me</div></body>你试一下这个就知道cancelBubble到底是怎么回事了 top.mainframeset.cols = "1,*";//改变mainframeset的宽度设置, top.contentbar.document.all("showtoc").style.display = "block";//设置showtoc的显示属性为使可见 top.mainframeset.cols = "1,*";//改变mainframeset的宽度设置,top.contentbar.document.all("showtoc").style.display = "block";//设置showtoc的显示属性为使可见多谢aotianlong(初中没毕业)但是mainframeset和contentbar都不是框架名,也就是说并不存在这样的代码<FRAME name="contentbar">,只是有一个名叫contentbar的asp文件代码如下,你也可以看看源文件:) <frameset rows="30,*" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> <frame name="fraContentBar" src="/expert/deeptree/contentbar.asp?xmlsrc=/Expert/deeptree/Rooms/List.xml&csdnstyle=&hidetoc=false&myie=ie" scrolling="no" border="0" frameborder="no" noresize></frame> <frame name="fraContent" src="/Expert/ForumList.asp?roomid=301&typenum=1" scrolling="yes" border="0" frameborder="no" noresize></frame> </frameset> function hidetoc() { top.mainframeset.cols = "1,*"; //id为mainframeset的frameset,只有frameset可以设置cols和rows top.contentbar.document.all("showtoc").style.display = "block";//对名为contentbar的框架里的页面做操作 } 楼上的老大,不存在名为mainframeset的frameset,也不存在名为contentbar的frame position:absolute;在IE中,此时,不一定是距窗口的的左上角来定位!如果它的父级元素中有设置了position:absolute的,就会按这个父级元素来定位。同时,在设置了position:absolute时,如果没有设置top/left,不会影响它在页面中的实际位置。知道了这两点,就很容易了,看这个:http://www.yesky.com/SoftChannel/72351167954550784/20030806/1719651.shtml 似乎只有frameset才有cols属性啊。mainframeset为frameset无疑 我不知道你是如何写的,可以看看这个测试<frameset id="mainframeset" rows="50,50" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> <frame name="fraContentBar" src="fff1.htm" scrolling="no" border="0" frameborder="no" noresize></frame> <frame name="fraContent" src="fff2.htm" scrolling="yes" border="0" frameborder="no" noresize></frame></frameset>fff1.htm<input type=button value=test onclick='top.mainframeset.rows = "100,*"'>fff2.htm<input type=button value=test onclick='top.mainframeset.rows = "*,100"'> xuzuning(唠叨):fff1.htm和fff2.htm都需要是框架文件,然后用fff1.htm中包含的一个文件中的脚本改变fff2.htm中包涵的一个文件中的一个图片的style属性别嫌我麻烦,csdn就是这样做的:) 点击目录树右上叫的叉,可以改变frameset的cols属性,同时显示右边的图片(显示菜单) function selectstart() { window.event.cancelBubble = true; //处理该事件,不让别其他元素看到. window.event.returnValue = false; //禁止执行默认动作. return false; }cancelBubble,returnValue 都是IE的事件对象.function hidetoc() { top.mainframeset.cols = "1,*"; //top最顶层.mainframeset是框架的名啊. top.contentbar.document.all("showtoc").style.display = "block"; }//这样写就行了.//top.RightFrame.RightTop.document.all("showdoc").style.display = "block"; 其实本站的源代码里已经很有了。出错一般是frame名字或者路径引起的 http://freedownload.myrice.com/lu/lucky/temp/XML.zip无帧的例子 是框架名,有可能在那src属性指定的asp文件将name名字改了也不准哦:)关键你要具体看看引用的asp文件中具体的代码是什么,看是不是有改frameset框架名字的代码 还没有解决:(我把代码都贴出来,大家帮我看看吧Frame.htm //主框架<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=gb2312"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> <TITLE>Welcome</TITLE> <SCRIPT LANGUAGE="JavaScript"> // this page should never load inside of another frame if (top.location != self.location) { top.location = self.location; } </SCRIPT> </HEAD> <FRAMESET rows="81,*" border="1" FRAMESPACING="0" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"> <FRAME name="fraToolbar" SRC="Top.htm" scrolling="no" border="0" frameborder="no" noresize TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"> </FRAME> <FRAMESET name="fstMain" cols="216,*" border="1" frameborder="1" FRAMESPACING="10" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"> <FRAME name="fraLeftFrame" src="LeftFrame.htm" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" FRAMEBORDER="1" BORDER="1"> </FRAME> <FRAME name="fraRightFrame" SRC="RightFrame.htm" FRAMEBORDER="no" BORDER="0" BORDERCOLOR="#6699CC"> </FRAME> </FRAMESET> </FRAMESET></HTML> 主框架中的3个页面,Top.htm,LeftFrame.htm,RightFrame.htmTop.htm 代码略LeftFrame.htm<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=gb2312"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> <TITLE>LeftFrame</TITLE> </HEAD> <frameset rows="21,*" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> <frame name="LeftTop" src="LeftTop.htm" scrolling="no" border="0" frameborder="no" noresize> </frame> <frame name="LeftTree" src="LeftTree.htm" scrolling="auto" border="0" frameborder="no" noresize> </frame> </frameset></HTML> LeftTree.htm生成树型结构,使用了moonpiazza提供的xml树代码,代码略。thanksLeftTop.htm<HTML> <HEAD> <TITLE>LeftTop</TITLE> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> <script language="JavaScript" type="text/JavaScript"> var strColumns_Current = "216,*"; function hidetoc() { strColumns_Current = top.fstMain.cols top.fstMain.cols = "1,*"; //工作正常 //top.fraRightFrame.RightTop.document.all("showtoc").style.display = "block"; //top.frames.fraRightFrame.frames.RightTop.document.all("showtoc").style.display = "block"; //以上两种写法都错:缺少对象 } function showtoc() { top.fstMain.cols = strColumns_Current; top.fstMain.RightFrame.document.all("showtoc").style.display = "none"; } function mouseover(item) { switch (item) { case "synctoc" : window.status = "同步菜单中的当前页"; document.all.imgSyncToc.src = "Images/synctoc2.gif" break; case "hidetoc" : window.status = "隐藏菜单"; document.all.imgHideToc.src = "Images/hidetoc2.gif" break; } } function mouseout(item) { switch (item) { case "synctoc" : window.status = ""; document.all.imgSyncToc.src = "Images/synctoc1.gif" break; case "hidetoc" : window.status = ""; document.all.imgHideToc.src = "Images/hidetoc1.gif" break; } } function selectstart() { window.event.cancelBubble = true; window.event.returnValue = false; return false; } </script> </HEAD><body onselectstart="selectstart();" bgcolor="#6699CC" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="100%"><DIV id="lefttop" align="right" height="20"><img id="imgHideToc" src="images/hidetoc1.gif" onclick="hidetoc();" onmouseover="mouseover('hidetoc');" onmouseout="mouseout('hidetoc');"></DIV> </td> </tr></table></body></HTML> 右边的框架RightFrame.htm<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=gb2312"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> <TITLE>RightFrame</TITLE> </HEAD> <frameset rows="21,*" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" name="RightFrame"> <frame name="RightTop" src="RightTop.htm" scrolling="no" border="0" frameborder="no" noresize> </frame> <frame name="RightMain" src="Welcome.htm" scrolling="auto" border="0" frameborder="no" noresize> </frame> </frameset></HTML> Welcome.htm代码略RightTop.htm<HTML> <HEAD> <TITLE>RightTop</TITLE> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> <script language="JavaScript" type="text/JavaScript"> function selectstart() { window.event.cancelBubble = true; window.event.returnValue = false; return false; } </script> </HEAD> <body onselectstart="selectstart();" bgcolor="#6699CC" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"> <DIV name="showtoc" align="right" height="20" style="display:none;"> <table width="100%" border="0" cellpadding="0" cellspacing="0" onclick="top.????.showtoc();" style="cursor:hand"> <!-- 上面的onclick事件也不知道该怎么写 --> <tr> <td width="30%"><img id="imgHideToc" src="images/showtoc.gif"><font face="verdana" color="#FFFFFF">显示目录树</font> </td> <td width="70%"></td> </tr> </table> </div></body></HTML> 第七届全国计算机信息大赛 移动互联网站(javascript+html)主观题 JS绑定数据后出现的问题 怎么解决这个缓动问题:当鼠标不停在3,4按钮上来回移动时,图片切换颤动问题。。。。 【easyui】datagrid的combobox动态添加数据源求解 十万火急!请问如何在DIV中增加图片热点? 文本框还剩多少字?? JS怎么样才能动态的改变行的背景色 在一个窗口A中打开了窗口B,B又转到窗口C上,在窗口C中如何让A刷新? 请教showModalDialog的问题,多谢! 一个日期的问题? 关于javascript的问题呀! 提取字符串中第三个字符的方法是什么?
{
window.event.cancelBubble = true;
window.event.returnValue = false;
return false;
}事件冒泡
<body onclick="alert('body')">
<div onclick="alert('div')">click me</div>
<div onclick="alert('div');event.cancelBubble=true">click me</div>
</body>
你试一下这个就知道cancelBubble到底是怎么回事了
top.contentbar.document.all("showtoc").style.display = "block";//设置showtoc的显示属性为使可见多谢aotianlong(初中没毕业)
但是mainframeset和contentbar都不是框架名,也就是说并不存在这样的代码
<FRAME name="contentbar">,只是有一个名叫contentbar的asp文件
代码如下,你也可以看看源文件:)
<frameset rows="30,*" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<frame name="fraContentBar" src="/expert/deeptree/contentbar.asp?xmlsrc=/Expert/deeptree/Rooms/List.xml&csdnstyle=&hidetoc=false&myie=ie" scrolling="no" border="0" frameborder="no" noresize></frame>
<frame name="fraContent" src="/Expert/ForumList.asp?roomid=301&typenum=1" scrolling="yes" border="0" frameborder="no" noresize></frame>
</frameset>
{
top.mainframeset.cols = "1,*"; //id为mainframeset的frameset,只有frameset可以设置cols和rows
top.contentbar.document.all("showtoc").style.display = "block";//对名为contentbar的框架里的页面做操作
}
在IE中,此时,不一定是距窗口的的左上角来定位!如果它的父级元素中有设置了position:absolute的,就会按这个父级元素来定位。同时,在设置了position:absolute时,如果没有设置top/left,不会影响它在页面中的实际位置。知道了这两点,就很容易了,看这个:http://www.yesky.com/SoftChannel/72351167954550784/20030806/1719651.shtml
mainframeset为frameset无疑
<frameset id="mainframeset" rows="50,50" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<frame name="fraContentBar" src="fff1.htm" scrolling="no" border="0" frameborder="no" noresize></frame>
<frame name="fraContent" src="fff2.htm" scrolling="yes" border="0" frameborder="no" noresize></frame>
</frameset>fff1.htm
<input type=button value=test onclick='top.mainframeset.rows = "100,*"'>fff2.htm
<input type=button value=test onclick='top.mainframeset.rows = "*,100"'>
别嫌我麻烦,csdn就是这样做的:)
{
window.event.cancelBubble = true; //处理该事件,不让别其他元素看到.
window.event.returnValue = false; //禁止执行默认动作.
return false;
}cancelBubble,returnValue 都是IE的事件对象.
function hidetoc()
{
top.mainframeset.cols = "1,*"; //top最顶层.mainframeset是框架的名啊.
top.contentbar.document.all("showtoc").style.display = "block";
}//这样写就行了.
//top.RightFrame.RightTop.document.all("showdoc").style.display = "block";
无帧的例子
关键你要具体看看引用的asp文件中具体的代码是什么,看是不是有改frameset框架名字的代码
我把代码都贴出来,大家帮我看看吧
Frame.htm //主框架
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<TITLE>Welcome</TITLE>
<SCRIPT LANGUAGE="JavaScript">
// this page should never load inside of another frame
if (top.location != self.location)
{
top.location = self.location;
}
</SCRIPT>
</HEAD>
<FRAMESET rows="81,*" border="1" FRAMESPACING="0" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<FRAME name="fraToolbar" SRC="Top.htm" scrolling="no" border="0" frameborder="no" noresize TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
</FRAME>
<FRAMESET name="fstMain" cols="216,*" border="1" frameborder="1" FRAMESPACING="10" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<FRAME name="fraLeftFrame" src="LeftFrame.htm" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" FRAMEBORDER="1" BORDER="1">
</FRAME>
<FRAME name="fraRightFrame" SRC="RightFrame.htm" FRAMEBORDER="no" BORDER="0" BORDERCOLOR="#6699CC">
</FRAME>
</FRAMESET>
</FRAMESET>
</HTML>
Top.htm 代码略
LeftFrame.htm
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<TITLE>LeftFrame</TITLE>
</HEAD>
<frameset rows="21,*" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<frame name="LeftTop" src="LeftTop.htm" scrolling="no" border="0" frameborder="no" noresize>
</frame>
<frame name="LeftTree" src="LeftTree.htm" scrolling="auto" border="0" frameborder="no" noresize>
</frame>
</frameset>
</HTML>
LeftTop.htm
<HTML>
<HEAD>
<TITLE>LeftTop</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<script language="JavaScript" type="text/JavaScript">
var strColumns_Current = "216,*";
function hidetoc()
{
strColumns_Current = top.fstMain.cols
top.fstMain.cols = "1,*"; //工作正常
//top.fraRightFrame.RightTop.document.all("showtoc").style.display = "block";
//top.frames.fraRightFrame.frames.RightTop.document.all("showtoc").style.display = "block"; //以上两种写法都错:缺少对象
}
function showtoc()
{
top.fstMain.cols = strColumns_Current;
top.fstMain.RightFrame.document.all("showtoc").style.display = "none";
}
function mouseover(item)
{
switch (item)
{
case "synctoc" :
window.status = "同步菜单中的当前页";
document.all.imgSyncToc.src = "Images/synctoc2.gif"
break; case "hidetoc" :
window.status = "隐藏菜单";
document.all.imgHideToc.src = "Images/hidetoc2.gif"
break;
} } function mouseout(item)
{
switch (item)
{
case "synctoc" :
window.status = "";
document.all.imgSyncToc.src = "Images/synctoc1.gif"
break; case "hidetoc" :
window.status = "";
document.all.imgHideToc.src = "Images/hidetoc1.gif"
break;
}
} function selectstart()
{
window.event.cancelBubble = true;
window.event.returnValue = false;
return false;
} </script>
</HEAD>
<body onselectstart="selectstart();" bgcolor="#6699CC" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%"><DIV id="lefttop" align="right" height="20"><img id="imgHideToc" src="images/hidetoc1.gif" onclick="hidetoc();" onmouseover="mouseover('hidetoc');" onmouseout="mouseout('hidetoc');"></DIV>
</td>
</tr>
</table>
</body>
</HTML>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<TITLE>RightFrame</TITLE>
</HEAD>
<frameset rows="21,*" border="0" framespacing="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" name="RightFrame">
<frame name="RightTop" src="RightTop.htm" scrolling="no" border="0" frameborder="no" noresize>
</frame>
<frame name="RightMain" src="Welcome.htm" scrolling="auto" border="0" frameborder="no" noresize>
</frame>
</frameset>
</HTML>
RightTop.htm
<HTML>
<HEAD>
<TITLE>RightTop</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<script language="JavaScript" type="text/JavaScript">
function selectstart()
{
window.event.cancelBubble = true;
window.event.returnValue = false;
return false;
}
</script>
</HEAD>
<body onselectstart="selectstart();" bgcolor="#6699CC" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<DIV name="showtoc" align="right" height="20" style="display:none;">
<table width="100%" border="0" cellpadding="0" cellspacing="0" onclick="top.????.showtoc();" style="cursor:hand">
<!-- 上面的onclick事件也不知道该怎么写 -->
<tr>
<td width="30%"><img id="imgHideToc" src="images/showtoc.gif"><font face="verdana" color="#FFFFFF">显示目录树</font>
</td>
<td width="70%"></td>
</tr>
</table>
</div>
</body>
</HTML>