<!
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=gb2312" />
< title ></ title >
< script language ="javascript" >
// author=askyes
function seturl()
{
var filepath = self.location.pathname;
var path = filepath.substr(filepath.lastIndexOf( " / " ) + 1 );
// document.write(path);
var searchString = self.location.search.substr( 1 );
var pageno = document.getElementById( " pageinput " ).value;
var searchTemp = "" ;
if (searchString.indexOf( " & " ) >- 1 )
{
var s = searchString.split( " & " );
for ( var i in s)
{
// 如果page=不再第一个参数
if (s[i].toLowerCase().indexOf( " &page= " ) >- 1 )
{
searchTemp += ( " page= " + pageno + " & " );
}
// 如果page=在第一个参数
else if (s[i].toLowerCase().substr( 0 , 5 ) == " page= " )
{
searchTemp += ( " page= " + pageno + " & " );
}
// 如果不包含page=
else
{
searchTemp += (s[i] + " & " );
}
}
// 如果还没有page
if (searchTemp.toLowerCase().indexOf( " &page= " ) ==- 1 && searchTemp.toLowerCase().substr( 0 , 5 ) != " page= " )
{
searchTemp += ( " page= " + pageno);
}
}
else if (searchString.length > 0 )
{
if ((searchString.toLowerCase().substr( 0 , 5 ) == " page= " ))
{
searchTemp = ( " page= " + pageno);
}
else
{
searchTemp = searchString + ( " &page= " + pageno);
}
}
else
{
searchTemp = ( " page= " + pageno);
}
// 如果最后包含了&
if (searchTemp.length == searchTemp.lastIndexOf( " & " ) + 1 )
{
searchTemp = searchTemp.toLowerCase().substr( 0 ,searchTemp.length - 1 );
}
if (pageno.replace( / ( ^ \s * ) | (\s * $) / g, "" ).length == 0 )
{
alert( " 请输入页码 " );
document.getElementById( " pageinput " ).focus();
document.getElementById( " pageinput " ).value = "" ;
return false ;
}
self.location = path + " ? " + searchTemp;
}
</ script >
</ head >
< body >
< input type ="text" id ="pageinput" name ="pageinput" />
< input type ="button" onclick ="seturl();" value ="转到页" />
</ body >
</ html >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" />
< title ></ title >
< script language ="javascript" >
// author=askyes
function seturl()
{
var filepath = self.location.pathname;
var path = filepath.substr(filepath.lastIndexOf( " / " ) + 1 );
// document.write(path);
var searchString = self.location.search.substr( 1 );
var pageno = document.getElementById( " pageinput " ).value;
var searchTemp = "" ;
if (searchString.indexOf( " & " ) >- 1 )
{
var s = searchString.split( " & " );
for ( var i in s)
{
// 如果page=不再第一个参数
if (s[i].toLowerCase().indexOf( " &page= " ) >- 1 )
{
searchTemp += ( " page= " + pageno + " & " );
}
// 如果page=在第一个参数
else if (s[i].toLowerCase().substr( 0 , 5 ) == " page= " )
{
searchTemp += ( " page= " + pageno + " & " );
}
// 如果不包含page=
else
{
searchTemp += (s[i] + " & " );
}
}
// 如果还没有page
if (searchTemp.toLowerCase().indexOf( " &page= " ) ==- 1 && searchTemp.toLowerCase().substr( 0 , 5 ) != " page= " )
{
searchTemp += ( " page= " + pageno);
}
}
else if (searchString.length > 0 )
{
if ((searchString.toLowerCase().substr( 0 , 5 ) == " page= " ))
{
searchTemp = ( " page= " + pageno);
}
else
{
searchTemp = searchString + ( " &page= " + pageno);
}
}
else
{
searchTemp = ( " page= " + pageno);
}
// 如果最后包含了&
if (searchTemp.length == searchTemp.lastIndexOf( " & " ) + 1 )
{
searchTemp = searchTemp.toLowerCase().substr( 0 ,searchTemp.length - 1 );
}
if (pageno.replace( / ( ^ \s * ) | (\s * $) / g, "" ).length == 0 )
{
alert( " 请输入页码 " );
document.getElementById( " pageinput " ).focus();
document.getElementById( " pageinput " ).value = "" ;
return false ;
}
self.location = path + " ? " + searchTemp;
}
</ script >
</ head >
< body >
< input type ="text" id ="pageinput" name ="pageinput" />
< input type ="button" onclick ="seturl();" value ="转到页" />
</ body >
</ html >