你的位置: Kiyo'Space首页 JavaScript/Jscript 阅读文章 欢迎留下您的足迹

自动判断电信网通并跳转

[ JavaScript/Jscript ] 分享

以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>站长资讯论坛-请选择最快的站点</title>
<script type="text/javascript">
var cookieEnabled=(navigator.cookieEnabled)? true : false
//判断cookie是否开启

//如果浏览器不是ie4+或ns6+
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){
document.cookie="testcookie"
cookieEnabled=(document.cookie=="testcookie")? true : false
document.cookie="" //erase dummy value
}

/*
 检查此IE是否支持cookie

*/ 
//document.cookie = 'killme' + escape('nothing')
function cc()
{
 if (document.cookie == "")
 {
  alert("请打开cookie选项");
  document.getElementById('message').style.display='';
  document.getElementById('setarea').style.display='none';
  window.setTimeout("goto();",3000) 
  document.Form1.cookieexists.value ="false"
 }
 else
 {
  Get();
 alert("你已经打开了cookie选项!!!!!");
 document.getElementById('setarea').style.display='';  
 }
}

function GetCookie(name)
{
     var arg=name+ "=";
     var alen=arg.length;
     var clen=document.cookie.length;
     var i=0;
     while (i<clen) {
       var j=i+alen;
       if(document.cookie.substring(i,j)
       ==arg)
       return getCookieVal(j);
       i=document.cookie.indexOf("",i)+1;
       if(i==0)break;
     }
     return null;
}

function getCookieVal(offset) {
     var endstr=document.cookie.indexOf
       (";",offset);
     if(endstr==-1) //没有指定其他元素
       endstr=document.cookie.length;
     return unescape(document.cookie.substring
       (offset,endstr));
   }

function Get()
{   
 if (cookieEnabled)
 {  
  var CookieArea = GetCookie('zz_area');
  //var CookieArea = "CNC";
  if (CookieArea == "CNC")
  {  
   document.getElementById('loading').style.display='';    
   document.getElementById('setarea').style.display='none';    
   this.location = "http://bbs2.chinahtml.com/index.php";
  }
  else
  {
   //判断电信线路
   if (CookieArea == "TEL")
   {
    document.getElementById('loading').style.display='';    
    document.getElementById('setarea').style.display='none';    
    this.location = "http://bbs.chinahtml.com/index.php";
   }
   else
   {
    document.getElementById('setarea').style.display='';
   }
  }
 }
 else
 {  
  this.location = "http://bbs.chinahtml.com/index.php";
 }
}
function SetCNC()
{
 var mydate = new Date();
 mydate.setTime(mydate.getTime() + 315360000000);
 document.cookie = "zz_area=CNC;expires="+ mydate.toGMTString() + ";domain=chinahtml.com";
 Get();
}
function SetTEL()
{
 var mydate = new Date();
 mydate.setTime(mydate.getTime() + 315360000000);
 document.cookie = "zz_area=TEL;expires=" + mydate.toGMTString() + ";domain=chinahtml.com";
 Get();
}
</script>
<body onload="Get()">
<div align="center" style="display:none">
<a href="http://bbs.chinahtml.com/index.php">电信论坛</a> | <a href="http://bbs2.chinahtml.com/index.php">网通论坛</a>
</div>
<table width="100%" height="180" border="0" cellspacing="0">
          <tr>
                    <td align="center" valign="bottom"><img src="http://bbs.chinahtml.com/images/misc/vbulletin3_logo_white.gif" width="180" height="60" /></td>
          </tr>

</table>
<table width="450" border="0" align="center" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
                    <td height="1" bgcolor="#FF6600"></td>
                    <td width="200" bgcolor="#FFFFFF"></td>
                    <td height="1" bgcolor="#FF6600"></td>
          </tr>
</table>
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>

                    <td width="1" bgcolor="#FF6600"></td>
                    <td>
<div id="message"  align="center" style="display:none">
 由于你的浏览器没有开启COOKIE功能(建议打开),系统将在3秒钟后,自动引导到站长资讯主服务器...
</div>
<div id="loading" align="center" style="display:none">
<br />
 正在装载,请稍候...
</div> 
<div id="setarea"  align="center" style="display:none">
 <br />
 请您选择最快的站点,此选项将不会再次出现<br /> <br />

 如您希望重新选择,请清除浏览器COOKIE<br /><br /><br />
 <input type="button" value="北方网通" onClick="SetCNC()">
 <input type="button" value="南方电信" onClick="SetTEL();">
 <input type="button" value="自动判断" onClick="javascript:window.location='auto.html'">
</div>

<br />
</td>
<td width="1" bgcolor="#FF6600"></td>
</tr>
</table>
<table width="450" height="1" border="0" align="center" cellspacing="0">
 <tr>
    <td bgcolor="#FF6600"></td>
 </tr>
</table>
</body>
</html>


欢迎在此留下您的脚步






评论内容 (*必填):
(Ctrl + Enter 快速提交)