首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请大家帮忙看下这段Javascript代码 可以放到JS 文件里面引用吗 该如何调用

2011-12-28 
请大家帮忙看下这段Javascript代码可以放到JS 文件里面引用吗 该怎么调用?不太懂这,请大家赐教代码如下:--

请大家帮忙看下这段Javascript代码 可以放到JS 文件里面引用吗 该怎么调用?
不太懂这,请大家赐教   代码如下:
------------------------------------------------------

<HTML> <HEAD> <TITLE> |> 2222 </TITLE>
<META   http-equiv=Content-Type   content= "text/html;   charset=gb2312 ">
!--   网站统一样式   --> <LINK   href= "qz.files/87846.htm "   type=text/css  
rel=stylesheet> <!--   亲子乐一级栏目统一样式   --> <LINK   href= "qz.files/mybaby.css "  
type=text/css   rel=stylesheet>


</HEAD>
<BODY>

<!--计数器-->

<!--head   结束--> <!--main   开始-->
<DIV   id=main>
<DIV   class=bg> <!--main01   开始-->


<DIV   id=left> <!--   left   bar   star-->
<DIV   id=left_bar>
<SCRIPT   language=javascript   type=text/javascript>
<!--left   bar   统一表现层js-->
//@06.07.18
//main   programe
function   show(action,channel_num,start_index,root_length){
for(var   n=start_index;n <root_length;n++){
document.getElementById( 'root '+n).style.display   =   'block ';
try{document.getElementById( 'sub '+n).style.display   =   'none ';}
catch(e){}
}
if   (action== 'open '){
document.getElementById( 'root '+channel_num).style.display   =   'none ';
document.getElementById( 'sub '+channel_num).style.display   =   'block ';
}
else{
document.getElementById( 'sub '+channel_num).style.display   =   'none ';
document.getElementById( 'root '+channel_num).style.display   =   'block ';
}
}
//add   channel   for   data
//参数opened   是否展开栏目
function   add_channel(name,   url,   opened)   {
this.opened   =   (opened==true)   ?   true   :   false;
this.name   =   name;
this.url   =   url;
this.sub_channel   =   new   Array();
}
//when   onmouseover,   then   change_class   this   background(   just   class   name)
function   change_class(object,class_name){
object.className=class_name;
}
//show   栏目
//参数   start_index   根目录开始索引数值  
//参数   root_length   根目录数组长度  
function   show_menu(start_index,root_length)
{          
<!--menu   star-->
document.write( ' <div   class= "menu "> ');
for   (var   i=start_index;i <root_length;i++){
if   (root[i].sub_channel.length!=0)
{
document.write( ' <div   id= "root '+i+ ' "   class= "root_close_onmouseout "   onmouseover= "change_class(this,\ 'root_close_onmouseover\ ') "   onmouseout= "change_class(this,\ 'root_close_onmouseout\ ') " ');
if   (   root[i].opened==true   )   {document.write( 'style= "display:none; " ');}
document.write( '> <a   href= "javascript:show(\ 'open\ ', '+i+ ', '+start_index+ ', '+root_length+ '); "   title= " '+openTitle+ ' "     target= "_self "> <div   class= "root_array "> </div> </a> <a   href= " '+root[i].url+ ' "   target= " '+target+ ' "   title= " '+goTitle+ ' "> <div   class= "root_text "> '+root[i].name+ ' </div> </a> </div> ');


document.write( ' <div   id= "sub '+i+ ' "   class= "sub " ');
if   (   root[i].opened==true   )   {document.write( 'style= "display:block; " ');}
document.write( '> ');
document.write( ' <div   class= "root_open_onmouseout "   onmouseover= "change_class(this,\ 'root_open_onmouseover\ ') "   onmouseout= "change_class(this,\ 'root_open_onmouseout\ ') "> <a   href= "javascript:show(\ 'close\ ', '+i+ ', '+start_index+ ', '+root_length+ '); "   title= " '+closeTitle+ ' "     target= "_self "> <div   class= "root_array "> </div> </a> <a   href= " '+root[i].url+ ' "   target= " '+target+ ' "   title= " '+goTitle+ ' "> <div   class= "root_text "> '+root[i].name+ ' </div> </a> </div> ');
<!--子栏目-->
for   (var   j=0;j <root[i].sub_channel.length-1;j++){
document.write( ' <a   href= " '+root[i].sub_channel[j].url+ ' "   target= " '+target+ ' "   title= " '+goTitle+ ' "   class= "sub_link "> <div   class= "sub_inner_onmouseout "   onmouseover= "change_class(this,\ 'sub_inner_onmouseover\ ') "   onmouseout= "change_class(this,\ 'sub_inner_onmouseout\ ') "> '+root[i].sub_channel[j].name+ ' </div> </a> ');      
}
document.write( ' <a   href= " '+root[i].sub_channel[root[i].sub_channel.length-1].url+ ' "   target= " '+target+ ' "   title= " '+goTitle+ ' "   class= "sub_link "> <div   class= "sub_inner_lastOne_onmouseout "     onmouseover= "change_class(this,\ 'sub_inner_lastOne_onmouseover\ ') "   onmouseout= "change_class(this,\ 'sub_inner_lastOne_onmouseout\ ') "> '+root[i].sub_channel[root[i].sub_channel.length-1].name+ ' </div> </a> ');        
document.write( ' </div> ');
}
else{
document.write( ' <div   id= "root '+i+ ' "   class= "root_close_onmouseout "   onmouseover= "change_class(this,\ 'root_close_onmouseover\ ') "   onmouseout= "change_class(this,\ 'root_close_onmouseout\ ') "> <div   class= "root_array "> </div> <a   href= " '+root[i].url+ ' "     target= " '+target+ ' "   title= " '+goTitle+ ' "> <div   class= "root_text "> '+root[i].name+ ' </div> </a> </div> ');
document.write( ' <div   id= "sub '+i+ ' "   class= "sub "   style= "display:none; "> ');
document.write( ' <div   class= "root_open_onmouseout "   onmouseover= "change_class(this,\ 'root_open_onmouseover\ ') "   onmouseout= "change_class(this,\ 'root_open_onmouseout\ ') "> <a   href= "javascript:show(\ 'close\ ', '+i+ ', '+start_index+ ', '+root_length+ '); "   title= " '+closeTitle+ ' "     target= "_self "> <div   class= "root_array "> </div> </a> <a   href= " '+root[i].url+ ' "   target= " '+target+ ' "   title= " '+goTitle+ ' "> <div   class= "root_text "> '+root[i].name+ ' </div> </a> </div> ');


document.write( ' </div> ');
}
}  
document.write( ' </div> ');
<!--menu结束-->
<!--   间隔-->
document.write( ' <div   id= "space "> </div> ');
}


[解决办法]
可以。放在js里也一样,把所有
<SCRIPT language=javascript type=text/javascript>

</SCRIPT> 之间的代码存成js文件,
<SCRIPT language=javascript type=text/javascript src= "xxx.js "> </SCRIPT> 调用即可

热点排行