新手求助js一菜单显示问题...

时间:2022-03-21 20:32:08
以下是163网页中的一段js代码,相关的是新闻和所定制的本地新闻菜单事件,里面很多都看不懂如何修改而实现滑动式显示需要的调用内容...

//local
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0)
       break;
  }
  return "";
}
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;domain=.163.com;expires="+expire.toGMTString();
}
var city = new Array("安徽","黑龙江","山东","北京","湖北","山西","福建","湖南","陕西","甘肃","吉林","上海","广东","江苏","四川","广西","江西","天津","贵州","辽宁","*","海南","内蒙古","*","河北","宁夏","云南","河南","青海","浙江","重庆");
var addr = new Array("ah","hlj","sd","bj","hubei","sx","fj","hunan","shanxi","gs","jl","sh","gd","js","sc","gx","jx","tj","guizhou","ln","xz","hainan","nmg","xj","hb","nx","yn","henan","qh","zj","cq");
var weaths = new Array('58321','50953','54823','54511','57494','53772','59134','57679','57036','52889','54172','58367','59287','58238','56294','59431','58606','54527','57816','54342','55591','52856','53463','51463','53698','53614','56778','57083','52866','58457','57516');

function getCityPage(aCity){
for(i=0;i<city.length;i++){
if(city[i]==aCity){
return "/inc/163new/" + addr[i] + "to163.html";
}
}
return "/inc/163new/bjto163.html";
}
function getCityWeatherID(cityname){
for(i=0;i<city.length;i++){
if(city[i]==cityname){
return weaths[i];
}
}
return "54511";
}
function getCityWeather(cityid){
return "/inc/weather/" + cityid + ".html";
}
var loc = GetCookie("theaddr");
if(!loc){
document.write("<script type='text/javascript' src='http://202.108.39.152/ipquery'><" + "/script>");
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var wloc = GetCookie("NTES_WeatherAddr");
if(!wloc){
wloc=getCityWeatherID(loc);
}
//定制地方新闻
function getLNewsHomeByCityName(aCity){
for(i=0;i<city.length;i++){
if(city[i]==aCity){
return "http://" + addr[i] + ".news.163.com";
}
}
return "http://bj.news.163.com";
}
function setLocNews(locstr){
var l=getElement("locbar");
l.setAttribute("href",getLNewsHomeByCityName(locstr));
l.setAttribute("urn",getCityPage(locstr));
l.innerHTML=locstr+"新闻";
}
function showLocSelect()
{
var locdiv=getElement("locListDiv");
if(locdiv.style.display=="block"){
locdiv.style.display="none";
return;
}
locdiv.style.display="block";
var locs=locdiv.getElementsByTagName("li");
for(var i=0;i<locs.length;i++)
{
var theloc=locs[i];
theloc.onmouseover=function(){
this.style.backgroundColor="#A0AAC8"
}
theloc.onmouseout=function(){
this.style.backgroundColor="#F2F6FB"
}
theloc.onclick=function(){
var locstr=this.innerHTML;
if (locstr.indexOf(" ")!=-1) locstr=locstr.substr(0,locstr.indexOf(" ")); //fixbug 在IE下多出一个空格
SetCookie("NTES_LocNewsAddr",locstr,365);
setLocNews(locstr);
hideLocSelect();
var l=getElement("locbar");
loadAJAXTab(l.getAttribute("urn"),l.getAttribute("rel"));
}
}
}
function hideLocSelect()
{
getElement("locListDiv").style.display="none";
}
document.onmousedown=function(aEvent){
var myEvent = window.event ? window.event : aEvent;
var lo=getElement("locListDiv");
if(!IsChild(myEvent.srcElement,lo))hideLocSelect();
}
//]]>


----------------------------
修改的相关地方....
<div class="menu" id="tabzero">
<ul>
<li class="activeW1"><h6><a href="http://news.163.com/" urn="#default_news" rel="zeroarea">新闻</a></h6></li>
<li class="normalW2"><h6><a href="#" id="locbar" urn="/inc/163new/news1.html" rel="zeroarea">地方新闻</a></h6>
<span style="position:relative"><a href="javascript:showLocSelect();" target="_self">订制 本地新闻</a>
<div id="locListDiv" class="placeList">
<div class="titleT"><h5>点击省份名称,订制您想要的本地新闻</h5></div>
<div class="contentT">

这个tabzero在下面:
<script type="text/javascript">
startajaxtabs("maintab","tabone","tabtwo","tabzero")
</script>

这段表示的是什么意思?

urn="#default_news" 

这个urn是定义吗?还是?


小弟曾删除过最上面的js代码,但在内容加上了调用的代码,但无法显示..


查看过很多资料.如果不使用div+css,可以用 <td width="90" id="tb_1" onMouseOver ="switchTab (this);" class="tb_on" align="center"><b>XXX</b></td>实现,但如果在div下如何实现?

请教各位高手如何修改才能实现上述所说的滑过式显示内容?

谢谢~~

2 个解决方案

#1


等我看完,我就需要配上一副眼镜

#2


没有人能解答下吗?

#1


等我看完,我就需要配上一副眼镜

#2


没有人能解答下吗?