I have used the second-level domain name redirection of ASP, but another method is used: the redirection of JS and ASP at the front end Program But it cannot be switched. The program debugging has passed, but it cannot be switched. I don't know why. Please help me identify the cause. Thank you !!!
<%
Dim whkdbq, whksql, whkrs, whkcount
Set whkconn = server. Createobject ("ADODB. Connection ")
Whkdbq = server. mappath ("sqltaofun. mdb ")
Whkconn. Open "provider = Microsoft. Jet. oledb.4.0; Data Source =" & whkdbq
Whksql = "select BH, ID from userinfo where State = '3 '"
Set whkrs = server. Createobject ("ADODB. recordset ")
Whkrs. Open whksql, whkconn, 3
%>
<Script language = "JavaScript">
VaR records = [], whkcoun = 0, whkflag = 0;
<%
Do while not whkrs. EOF
%>
Records [whkcoun] = new array ("<% = whkrs (" bh ") %>", "<% = whkrs (" ID ") %> ");
Document. write ("whkcoun:" + whkcoun + "records [" + whkcoun + "]: "+ records [whkcoun] [0] + records [whkcoun] [1] +" <br> ");
Whkcoun = whkcoun + 1;
<%
Whkrs. movenext
'Whkconn = whkconn + 1
Loop
'Response. End ()
%>
Whkurl = Document. Location. href;
Document. Write (whkurl)
Whkurl = whkurl. Replace ("http ://","");
Whkurl = whkurl. substring (0, whkurl. indexof ("/"));
Document. Write ("<br> whkurl:" + whkurl );
If (whkurl. tolowercase ()! = "Www.taofun.cn ")
{
VaR whkfirstp = whkurl. indexof ("."), whkendp = whkurl. lastindexof ("."), gotourl;
If (whkfirstp = whkendp) & (whkfirstp! =-1) | (whkendp! =-1 )))
{
Whkflag = 0;
Window. Alert ("taofun.cn ");
// Window. Location. href = "http://www.taofun.cn /"
}
Else
{
If (whkurl = "localhost ")
{
Whkflag = 0;
Window. Alert ("localhost ");
}
Else
{
VaR whkurl2 = whkurl. substring (0, whkurl. indexof ("."));
Document. Write ("<br> whkurl2:" + whkurl2 );
If (whkurl2.tolowercase () = "www ")
{
If (whkurl. indexof (".", whkfirstp + 1) = whkurl. lastindexof (".", whkEndP-1 ))
For (I = 0; I <whkcoun; I ++)
{
Document. Write ("<br> the read BH:" + records [I] [0]);
If (records [I] [0] = whkurl. substring (whkfirstp + 1, whkurl. indexof (".", whkfirstp + 1 )))
{
Whkflag = 1;
Gotourl = "http://www.taofun.cn/show/Shop.asp? Id = "+ records [I] [1];
Window. Alert ("find" + records [I] [0] + "second-level domain name. ");
Break;
}
}
Else
{
Whkflag = 0;
Window. Alert ("too many inputs! ");
// Window. Location. href = "http://www.taofun.cn /";
}
}
Else
{
Whkflag = 0;
Window. Alert ("Start with www ");
// Window. Location. href = "http://www.taofun.cn /";
}
}
}
}
Else
{
Whkflag = 0;
Window. Alert ("go to the homepage! ");
// Window. Location. href = whkurl;
}
Document. Write ("<br> final result:" + gotourl + whkwhkwhk );
If (whkflag = 1)
{
Document. write ("<frameset Cols = \" * \ "> <frame frameborder = \" 0 \ "scrolling = \" auto \ "src = \" "+ gotourl + "\"> <\/frameset> ");
}
</SCRIPT>