我发现了出问题的关键地方了,是下面几句: var str=this.location.href; //当前页面的路径 var u=str.indexOf("/"); var new_str=str.substring(0,u);我原本是用这几句来取类似http://www.sina.com.cn/这样的地址,结果只得到了http:继续想怎么得到第三个“/”符号之前的字符数。
function switchSysBar() { // //获取页面路径 // var path = ""; var href = document.location.href; var s = href.split("/"); for (var i=2;i<(s.length-1);i++) { path+=s[i]+"/"; } i=s.length-1; path=s[1]+s[2]; var url = window.location.protocol + "//" + path+"/";
if (top.document.all("fstMain").cols = "166,10,*") {
<!--
function change()
{
if(zuo.style.display=="none")
{
zuo.style.display="";
dot.innerText="<<"; }
else
{
zuo.style.display="none";
dot.innerText=">>";
}
}
//-->
</SCRIPT>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="400" style="font-size:12px">
<tr>
<td width="200" valign="top" bgcolor="#FF9966" id="zuo"> </td>
<td width="10" align="center" bgcolor="#FFCC00" style="cursor:hand" onclick="change();" id="dot"><<</td>
<td valign="top" bgcolor="#669900"> </td>
</tr>
</table>
var u=str.indexOf("/");
var new_str=str.substring(0,u);我原本是用这几句来取类似http://www.sina.com.cn/这样的地址,结果只得到了http:继续想怎么得到第三个“/”符号之前的字符数。
<!--
function switchSysBar()
{
//
//获取页面路径
//
var path = "";
var href = document.location.href;
var s = href.split("/");
for (var i=2;i<(s.length-1);i++) {
path+=s[i]+"/";
}
i=s.length-1;
path=s[1]+s[2];
var url = window.location.protocol + "//" + path+"/";
if (top.document.all("fstMain").cols = "166,10,*")
{
switchPoint.src=url+"images/ArrowRight.gif";
top.document.all("fstMain").cols = "0,10,*";
}
else
{
switchPoint.src=url+"images/ArrowLeft.gif";
top.document.all("fstMain").cols = "166,10,*";
}
}
-->
</SCRIPT>