手机浏览网站自动跳转到wap页面的代码
分类:网页设计 Tags: 手机网站 wap 评论:3 浏览:8419 最近更新时间:2015/3/16 11:24:42
手机访问网站域名时如果实现自动跳转到wap页面 ?
如何让用户输入wap手机网站的网址时自动跳转到wap网站 ?
wap页面自动跳转的实现方式 ?
如何判断访客是否是移动设备访问,自动跳转到wap页面 ?
手机自动跳转到手机页面,一个网址区分普通访问与手机访问 ?
本文就可以解决这些问题!
PHP检测代码:
function is_mobile() {
var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i;
var u = navigator.userAgent;
if (null == u) {
return true;
}
var result = regex_match.exec(u);
if (null == result) {
return false
} else {
return true
}
}
if (is_mobile()) {
document.location.href= 'http://www.yuzhiguo.com/wap';
}ASP检测代码:
HTTP_ACCEPT=Request.ServerVariables("HTTP_ACCEPT") '获取浏览器信息
HTTP_USER_AGENT=LCase(Request.ServerVariables("HTTP_USER_AGENT")) '获取AGENT
HTTP_X_WAP_PROFILE=Request.ServerVariables("HTTP_X_WAP_PROFILE") 'WAP特定信息 品牌机自带浏览器都会有
HTTP_UA_OS=Request.ServerVariables("HTTP_UA_OS") '手机系统 电脑为空
HTTP_VIA=LCase(Request.ServerVariables("HTTP_VIA")) '网关信息
Dim WapStr
WAPstr=False
If ubound(split(HTTP_ACCEPT,"vnd.wap"))>0 Then WAPstr=True
If HTTP_USER_AGENT="" Then WAPstr=True
If HTTP_X_WAP_PROFILE<>"" Then WAPstr=True
If HTTP_UA_OS<>"" Then WAPstr=True
IF ubound(split(HTTP_VIA,"wap"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"netfront"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"iphone"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"opera mini"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"ucweb"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"windows ce"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"symbianos"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"java"))>0 Then WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"android"))>0 Then WAPstr=True
If WAPstr=True Then
'手机网址
response.redirect "http://www.yuzhiguo.com/wap"
else
'电脑网址
response.redirect "http://www.yuzhiguo.com"
End ifJs代码:
<script type="text/javascript">
try {
var urlhash = window.location.hash;
if (!urlhash.match("fromapp"))
{
if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{
window.location="http://www.yuzhiguo.com/wap";
}
}
}
catch(err)
{
}</script>本文地址:/523/
-
• 教你如何免费申请google企业邮局(10个用户,每个用户7G邮箱空间)
• 如何使iframe自适应大小?
• Dreamweaver cs3新功能Spry效果介绍
• 如何给表单文本域加上背景(图)
• 如何给网站制作一个favicon.ico图标,附代码(图)
• 中式网站之古典风格网址
• 手机浏览网站自动跳转到wap页面的代码
• 网页虚线代码\表格边框虚线代码大全
• 鼠标点上去显示闪烁动态效果代码
• 【原创】如何自学做网站?自学做网页需要学什么?
3.
Philipkek
: Современная система очистки играет решающую роль в комфортной жизни.
Подобная технология помогает нейтрализовать вредные вещества из воды.
При качественной фильтрации, тем здоровее становится домашняя вода.
Многие семьи оценивают необходимость
2025/11/25 4:46:04