小糊涂网站建设提供代码如下,两种写法,都是判断是否是域名http://www.wantemplates.com访问,如果不是跳转到http://www.wantemplates.com
var _classie = ["domain", "want", "indexOf", "127.0.0.1", "localhost", "emplates", "com", "www.", "http://"]; var _classie0x1 = _classie[1] + _classie[5] + "." + _classie[6]; var _classie0x2 = _classie[7] + _classie0x1; host = window.location.host; if (host == _classie0x1) { } else if (host == _classie0x2) { } else { window.location.href = _classie[8] + _classie[7] + _classie0x1; };
var $port = window.location.port; var aAu = ["domain", "want", "indexOf", "127.0.0.1", "localhost", "emplates", "com", "www.", "http://", $port]; var _aAuHostx1 = aAu[1] + aAu[5] + "." + aAu[6]; var _aAuHostx2 = aAu[7] + _aAuHostx1; var _aAuHostx3 = aAu[4] + ":" + aAu[9]; host = window.location.host; if (host == _aAuHostx1) { } else if (host == _aAuHostx2) { } else if (host == _aAuHostx3) { } else { window.location.href = aAu[8] + aAu[7] + _aAuHostx1 }