判断访问页面的是 判断手机还是电脑访问问 还是 手机访问

他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)如何判断访问wap页面的是手机浏览器还是电脑浏览器?-CSDN论坛
如何判断访问wap页面的是手机浏览器还是电脑浏览器?
首先请问手机上网格式有几种?
我的网站做了3套程序,
1,提供给电脑用户的,常见的ASP页面
2,提供给HTTP协议手机上网用户浏览的&&html小界面网页
3,提供给??协议手机上网用户浏览的&&wml小界面网页
重点是2和3,现在很多手机支持访问html页面了,所以
我希望如果支持html的手机&我希望他跳转到类型(2)
我希望如果只支持wml的手机&我希望他跳转到类型(3)
如何判断?
关注一下!
有没有人帮忙下啊
获最终端浏览器呀,手机和电脑用的不一样,而电脑里也有可能不一样的。
如果是手机用户,那怎么知道用户是什么协议&或者&什么格式&上网的。
因为&我要将用户跳转到(1)小界面的HTML网页或者(2)WML网页。
For&Each&key&In&Request.ServerVariables
&&&&Response.Write&key&&&"&=&"&&&Request.ServerVariables(key)&&&"&br/&"
PC和手机访问,然后自己去对比一下,有什么不同,从这不同可以判断PC和手机
我再一次重复我的问题:
[size=54px]如果是手机用户,那怎么知道用户是什么协议&或者&什么格式&上网的。
因为&我要将用户跳转到(1)小界面的HTML网页或者(2)WML网页。[/size]
不会,搭车学习
让你自己对比服务器环境变量,你怎么不去对比呢?告诉你几点可以对比的服务器变量
1、HTTP_ACCEPT
PC一般是有这些关键字:text/html,&application/xml,&application/xhtml+xml
MOBILE一般是这几个:text/vnd.wap.wml,&application/vnd.wap.xhtml+xml,&或者&其他包含wap的MIME头
2、HTTP_USER_AGENT
PC一般都有自己的关键字,例如:MSIE,Opera,gecko
MOBILE现在一般获取不到这个变量,这样的话就从UA判断,text/vnd.wap.wml支持WML标签,application/vnd.wap.xhtml+xml支持XHTML-MOBILE标签
3、HTTP_UA_OS
PC没有这个变量
MOBILE里的智能手机一般有这个变量,例如一些关键字:Symbain,&Windows&CE,&Linux,这类手机大部分支持XHTML-Mobile标签
综合这三点不同,用排除法将PC和MOBILE分辨出来,一般Opera支持wml,如果要用Opera测试WAP,最好把这个判断也算作WML标签
&&&&&&&&HttpCapabilitiesBase&r&=&(System.Web.Configuration.HttpCapabilitiesBase)Request.B
&&&&&&&&string&agent&=&(Request.UserAgent&+&"").ToLower().Trim();&
if&(r.Browser&==&"Mozilla")
&&&&&&&&&&&&Response.Write("可以识别:Mozilla");
&&&&&&&&else
&&&&&&&&&&&&Response.Write("不识别:Mozilla");
&&&&&&&&if&(r.IsMobileDevice&||&r.Browser&==&"Unknown"&||&r.Browser&==&"Mozilla")
&&&&&&&&&&&&Response.Write("手机"&+&"\r\n"&+&r.Browser&+&"\r\n"&+&r.Type);
&&&&&&&&else
&&&&&&&&&&&&Response.Write("电脑"&+&"\r\n"&+&r.Browser&+&"\r\n"&+&r.Type);
&&&&&&&&}&
回复1被浏览146分享邀请回答暂时还没有回答,开始写第一个回答yii如何判断是手机访问还是电脑访问 - 问答 - Yii Framework 中文网
yii如何判断是手机访问还是电脑访问
2156次浏览
悬赏 20 金钱
大神好 求yii如何判断是手机访问还是电脑访问
帅哥,不用纠结了,Yii官方是没有提供方法去判断来源是移动设备还是PC的,包括其核心代码以及扩展代码。
在服务器和客户端的 HTTP 交互中,客户端会通过请求头中的 User-Agent 告知服务器客户端到底是啥玩意。你可以直接获取 这个 User-Agent,不过基于 CGI 协议,PHP可以直接用 $_SERVER['HTTP_USER_AGENT']获取这个 User-Agent。但不幸的是,它是一大堆字符串,人们虽然可能可以通过其直接判断是移动设备还是PC,但程序却很麻烦,毕竟难免有所疏漏之处。所以有专门的人士去做自然最好。,这个程序可以的。star 六千,还专门为 Yii 写个了扩展,应该不会辱没帅哥你的程序的。。
共 7 条回复谢谢 大神 我以为yii自己有这个方法那
不用谢,采纳呀,采纳就是最好的感谢。。
大神 这个判断手机的方法我如何使用 比如给个成功的例子 或者给个好的教程 我看了下面的教程 我不知道如何做
这里面的教程似乎改了 我看不懂 大神
ctrl+f 搜索下 yii,看到那个为yii2写的扩展的链接
然后照做咯。
英文不好使实在是伤啊
大神 这样吧 我们以yii2普通版为例
里面的例子下载后 我把它放在那里 之后如何配置 如何调用 如何访问 大神 我小菜求指导或者加我QQ 大神辛苦了
好吧,收人钱财,替人消灾。。
共 5 条回复
你是百度派来的
大神 我是说yii如何判断的
这个跟yii没有关系,都是软件底层的玩意儿。还就是判断用户传来的浏览器标识。
我是想贴google的链接,怕你们梯子不够长。
你们的对话真有意思
composer下一个
共 1 条回复
composer下一个 什么意思 求指导
可以使用 $_SERVER['HTTP_USER_AGENT'] 来进行判断~,然后可以继承 baseModel来封装成一个类中的判断方法~希望可以帮到你
共 1 条回复
那也不算是 yii的方法把
yii框架没有的。 可以用这个
共 1 条回复
这个我用过 没成功
我用的别的方法 如下面的代码 但yii真的没有吗
还是我们不知道
//手机网页跳转
//如果检测到访问的浏览器为下列一个指定的移动浏览器 则返回true
function is_mobile(){
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
$is_mobile=is_mobile();
if($is_mobile){
//这是一个手机浏览器,可以跳转到手机版网页
//header("Location: http://www.abc.com/3g");
echo "手机访问";
//这不是一个手机浏览器
//header("Location: http://www.abc.com/desktop");
echo "电脑访问";
// These lines are mandatory.
require_once 'Mobile_Detect.php';
$detect = new Mobile_D
// Basic detection.
$detect-&isMobile();
$detect-&isTablet();
// Magic methods.
$detect-&isIphone();
$detect-&isSamsung();
// Alternative to magic methods.
$detect-&is('iphone');
// Find the version of component.
$detect-&version('Android');
// Additional match method.
$detect-&match('regex.*here');
// Browser grade method.
$detect-&mobileGrade();
// Batch methods.
$detect-&setUserAgent($userAgent);
$detect-&setHttpHeaders($httpHeaders);
// Check for mobile environment.
if ($detect-&isMobile()) {
// Your code here.
// Check for tablet device.
if($detect-&isTablet()){
// Your code here.
// Check for any mobile device, excluding tablets.
if ($detect-&isMobile() && !$detect-&isTablet()) {
// Your code here.
Keep the value in $_SESSION for later use
and for optimizing the speed of the code.
if(!$_SESSION['isMobile']){
$_SESSION['isMobile'] = $detect-&isMobile();
// Redirect the user to your mobile version of the site.
if($detect-&isMobile()){
header('http://m.yoursite.com', true, 301);
// Include and instantiate the class.
require_once 'Mobile_Detect.php';
$detect = new Mobile_D
// Any mobile device (phones or tablets).
if ( $detect-&isMobile() ) {
// Any tablet device.
if( $detect-&isTablet() ){
// Exclude tablets.
if( $detect-&isMobile() && !$detect-&isTablet() ){
// Check for a specific platform with the help of the magic methods:
if( $detect-&isiOS() ){
if( $detect-&isAndroidOS() ){
// Alternative method is() for checking specific properties.
// WARNING: this method is in BETA, some keyword properties will change in the future.
$detect-&is('Chrome')
$detect-&is('iOS')
$detect-&is('UCBrowser')
$detect-&is('Opera')
// Batch mode using setUserAgent():
$userAgents = array(
'Mozilla/5.0 (L Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0. Mobile Safari/535.19',
'BlackBerry.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/103',
foreach($userAgents as $userAgent){
$detect-&setUserAgent($userAgent);
$isMobile = $detect-&isMobile();
$isTablet = $detect-&isTablet();
// Use the force however you want.
// Get the version() of components.
// WARNING: this method is in BETA, some keyword properties will change in the future.
$detect-&version('iPad'); // 4.3 (float)
$detect-&version('iPhone') // 3.1 (float)
$detect-&version('Android'); // 2.1 (float)
$detect-&version('Opera Mini'); // 5.0 (float)
共 1 条回复
这个tp框架封装了的,直接复制出来用
您需要登录后才可以回答。 |js判断是手机访问还是电脑访问
&script type=&text/javascript&&
//平台、设备和操作
var system ={
win : false,
mac : false,
xll : false
//检测平台
var p = navigator.
system.win = p.indexOf(&Win&) == 0;
system.mac = p.indexOf(&Mac&) == 0;
system.x11 = (p == &X11&) || (p.indexOf(&&) == 0);
//跳转语句
if(system.win||system.mac||system.xll){//转向后台登陆页面
window.location.href=&login.&;
window.location.href=&wapLojin.jsp&;

我要回帖

更多关于 hbuilder手机访问页面 的文章

 

随机推荐