一些JS

网页高亮导航
None.gif// JavaScript Document
ExpandedBlockStart.gifContractedBlock.gif
function addLoadEvent(func) dot.gif{
InBlock.gif  
var oldonload = window.onload;
ExpandedSubBlockStart.gifContractedSubBlock.gif  
if (typeof window.onload != 'function') dot.gif{
InBlock.gif    window.onload 
= func;
ExpandedSubBlockStart.gifContractedSubBlock.gif  }
 else dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    window.onload 
= function() dot.gif{
InBlock.gif      oldonload();
InBlock.gif      func();
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif}

None.gif
ExpandedBlockStart.gifContractedBlock.gif
function insertAfter(newElement,targetElement) dot.gif{
InBlock.gif  
var parent = targetElement.parentNode;
ExpandedSubBlockStart.gifContractedSubBlock.gif  
if (parent.lastChild == targetElement) dot.gif{
InBlock.gif    parent.appendChild(newElement);
ExpandedSubBlockStart.gifContractedSubBlock.gif  }
 else dot.gif{
InBlock.gif    parent.insertBefore(newElement,targetElement.nextSibling);
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif}

None.gif
ExpandedBlockStart.gifContractedBlock.gif
function addClass(element,value) dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
if (!element.className) dot.gif{
InBlock.gif    element.className 
= value;
ExpandedSubBlockStart.gifContractedSubBlock.gif  }
 else dot.gif{
InBlock.gif    newClassName 
= element.className;
InBlock.gif    newClassName
+= " ";
InBlock.gif    newClassName
+= value;
InBlock.gif    element.className 
= newClassName;
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif}

None.gif
ExpandedBlockStart.gifContractedBlock.gif
function highlightPage() dot.gif{
InBlock.gif  
if (!document.getElementsByTagName) return false;
InBlock.gif  
if (!document.getElementById) return false;
InBlock.gif  
if (!document.getElementById("navigation")) return false;
InBlock.gif  
var nav = document.getElementById("navigation");
InBlock.gif  
var links = nav.getElementsByTagName("a");
ExpandedSubBlockStart.gifContractedSubBlock.gif  
for (var i=0; i<links.length; i++dot.gif{
InBlock.gif    
var linkurl = links[i].getAttribute("href");
InBlock.gif    
var currenturl = window.location.href;
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if (currenturl.indexOf(linkurl) != -1dot.gif{
InBlock.gif      links[i].className 
= "here";
InBlock.gif      
var linktext = links[i].lastChild.nodeValue.toLowerCase();
InBlock.gif      document.body.setAttribute(
"id",linktext);
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif}

None.gif
None.gifaddLoadEvent(highlightPage);
None.gif
None.gif
None.gif

转载于:https://www.cnblogs.com/flyingchen/archive/2007/03/10/670538.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值