关于当前栏目的定位,用ASP可以轻松得到当前的文件名,然用再if下。
现在用的是iframe包含ASP文件,这样是不能判断的。
如果用iframe,那么父页面是不能得到iframe页面中的诸如CSS等的属性。
top.asp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>myprograme</title>
<link rel="stylesheet" href="../main.css" />
</head>
<Script>
function swap(){
a=location.href
filename=a.substring(a.lastIndexOf("/")+1,a.indexOf(".",a.lastIndexOf("/"))+4)
//alert(filename) 取得当前的文件名
parenturl=window.parent.location.href
parentfilename=parenturl.substring(parenturl.lastIndexOf("/")+1,parenturl.indexOf(".",parenturl.lastIndexOf("/"))+4)
//alert(parenturl)
//alert(parentfilename) 取得父页面的文件名,就是哪个页面包含了它,top.asp。
if(parentfilename=="index.htm"){
//alert(filename)
image1.src="../images/guide_01-.jpg" //判断,更改图片的src。
}
else{
image1.src="../images/guide_01.jpg"
}
if(parentfilename=="aboutus.htm"){
image2.src="../images/guide_02-.jpg"
}
else{
image2.src="../images/guide_02.jpg"
}
if(parentfilename=="secure.htm"){
image3.src="../images/guide_03-.jpg"
}
else{
image3.src="../images/guide_03.jpg"
}
if(parentfilename=="research.htm"){
image4.src="../images/guide_04-.jpg"
}
else{
image4.src="../images/guide_04.jpg"
}
if(parentfilename=="vulArea.htm"){
image5.src="../images/guide_05-.jpg"
}
else{
image5.src="../images/guide_05.jpg"
}
if(parentfilename=="news.htm"||parentfilename=="detailinfo.htm"){
image6.src="../images/guide_06-.jpg"
}
else{
image6.src="../images/guide_06.jpg"
}
if(parentfilename=="resource.htm"){
image7.src="../images/guide_07-.jpg"
}
else{
image7.src="../images/guide_07.jpg"
}
if(parentfilename=="teacher.htm"){
image8.src="../images/guide_08-.jpg"
}
else{
image8.src="../images/guide_08.jpg"
}
}
</script>
<body onload=swap()>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="92" colspan="4"><img src="../images/logo.jpg" height="92"/></td>
</tr>
<tr>
<td width="170" height="55" valign="top" style="background:url(../images/tbg.jpg);repeat-x;"></td>
<td valign="top" background="../images/tbg.jpg"><a href="../index.html" target="_parent"><img src="../images/guide_01.jpg" name="image1" width="48" height="55" border="0" id="image1" /></a><a href="../aboutus.html" target="_parent"><img src="../images/guide_02.jpg" name="image2" width="74" height="55" border="0" id="image2" /></a><a href="../secure.html" target="_parent"><img src="../images/guide_03.jpg" name="image3" width="74" height="55" border="0" id="image3" /></a><a href="../research.html" target="_parent"><img src="../images/guide_04.jpg" name="image4" width="74" height="55" border="0" id="image4" /></a><a href="../vulArea.html" target="_parent"><img src="../images/guide_05.jpg" name="image5" width="86" height="55" border="0" id="image5" /></a><a href="../news.html" target="_parent"><img src="../images/guide_06.jpg" name="image6" width="74" height="55" border="0" id="image6" /></a><a href="../resource.html" target="_parent"><img src="../images/guide_07.jpg" name="image7" width="74" height="55" border="0" id="image7" /></a><a href="../teacher.html" target="_parent"><img src="../images/guide_08.jpg" name="image8" width="70" height="55" border="0" id="image8" /></a></td>
</tr>
</table>