<script language="javascript" type="text/javascript">
thisURL = document.URL;
host=thisURL.substring(0,thisURL.indexOf("/",7)+1);
thisHREF = document.location.href;
tmpPage = thisHREF.split( "/" );
thisPage = tmpPage[tmpPage.length-1];
thisPage=thisPage.substring(0,thisPage.indexOf("."));
if(thisPage.indexOf("?")>-1){
page=thisPage.substring(0,thisPage.indexOf("?"));
}else{
page=thisPage;
}
//document.write(document.getElementById("index").innerHTML);
if(page!=""){
document.getElementById(page).addClass="current";
}else{
document.getElementById("index").addClass="current";
}
</script>
<div id="templatemo_header">
<div id="templatemo_logo">
<h1>YIYANG18 dress</h1>
<h2>make solution</h2>
</div>
<div id="templatemo_menu">
<ul>
<li id="index"><a href="index.php"><b>首页</b></a></li>
<li id="solution"><a href="solution.php"><b>制作方案</b></a></li>
<li id="newsT"><a href="newsT.php"><b>新款T恤</b></a></li>
<li id="class"><a href="class.php"><b>分类查询</b></a></li>
<li id="guide"><a href="guide.php"><b>订作指南</b></a></li>
<li id="about"><a href="about.php"><b>关于我们</b></a></li>
</ul>
</div>
</div>
页面跳转后,样式添加不上。大家帮看看。
thisURL = document.URL;
host=thisURL.substring(0,thisURL.indexOf("/",7)+1);
thisHREF = document.location.href;
tmpPage = thisHREF.split( "/" );
thisPage = tmpPage[tmpPage.length-1];
thisPage=thisPage.substring(0,thisPage.indexOf("."));
if(thisPage.indexOf("?")>-1){
page=thisPage.substring(0,thisPage.indexOf("?"));
}else{
page=thisPage;
}
//document.write(document.getElementById("index").innerHTML);
if(page!=""){
document.getElementById(page).addClass="current";
}else{
document.getElementById("index").addClass="current";
}
</script>
<div id="templatemo_header">
<div id="templatemo_logo">
<h1>YIYANG18 dress</h1>
<h2>make solution</h2>
</div>
<div id="templatemo_menu">
<ul>
<li id="index"><a href="index.php"><b>首页</b></a></li>
<li id="solution"><a href="solution.php"><b>制作方案</b></a></li>
<li id="newsT"><a href="newsT.php"><b>新款T恤</b></a></li>
<li id="class"><a href="class.php"><b>分类查询</b></a></li>
<li id="guide"><a href="guide.php"><b>订作指南</b></a></li>
<li id="about"><a href="about.php"><b>关于我们</b></a></li>
</ul>
</div>
</div>
页面跳转后,样式添加不上。大家帮看看。
<script language="javascript" type="text/javascript">
window.onload = function(){//写在onload里,否则找不到对象,肯定加不上。
thisURL = document.URL;
host=thisURL.substring(0,thisURL.indexOf("/",7)+1);
thisHREF = document.location.href;
tmpPage = thisHREF.split( "/" );
thisPage = tmpPage[tmpPage.length-1];
thisPage=thisPage.substring(0,thisPage.indexOf("."));
if(thisPage.indexOf("?")>-1){
page=thisPage.substring(0,thisPage.indexOf("?"));
}else{
page=thisPage;
}
//document.write(document.getElementById("index").innerHTML);
if(page!=""){
document.getElementById(page).addClass="current";
}else{
document.getElementById("index").addClass="current";//一般这样写:style.className='current';
}
}
</script>
document.getElementById(page).className="current";
window.onload = function(){
thisURL = document.URL;
host=thisURL.substring(0,thisURL.indexOf("/",7)+1);
thisHREF = document.location.href;
tmpPage = thisHREF.split( "/" );
thisPage = tmpPage[tmpPage.length-1];
thisPage=thisPage.substring(0,thisPage.indexOf("."));
if(thisPage.indexOf("?")>-1){
page=thisPage.substring(0,thisPage.indexOf("?"));
}else{
page=thisPage;
}
//document.write(document.getElementById("index").innerHTML);
if(page!=""){
document.getElementById(page).className="current";
}else{
document.getElementById("index").className="current";
}
}
</script>