如果一个网站从移动浏览器起源

如果一个网站从移动浏览器起源

本文介绍了我将如何确定,如果一个网站从移动浏览器起源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在开发一个网站,一个手机一个完全不同的世界?

Is developing a website for a cellphone a totally different world?

我将如何检测网页是否从计算机或从手机访问的?

How would I detect whether a page is visited from computer or from a cellphone?

我问这个,因为我看到类似下面的代码:

I ask this because I see code like below:

if (isset($_SERVER['HTTP_ACCEPT']) &&
(strpos($_SERVER['HTTP_ACCEPT'],'vnd.wap.wml')!==FALSE)
&& (strpos($_SERVER['HTTP_ACCEPT'],'text ml') === FALSE
||
(strpos($_SERVER['HTTP_ACCEPT'],'vnd.wap.wml') <
strpos($_SERVER['HTTP_ACCEPT'],'text ml'))

)) { //cellphone

   readfile('index.wml');

} else readfile('index.htm');



我如何将代码移植到C#?

How do I port the code into C#?

推荐答案

在PHP中,你通常会检查 $ _ SERVER ['HTTP_USER_AGENT'] 头,以确定从哪里Web浏览器Web请求发起。

In php you would typically check the $_SERVER['HTTP_USER_AGENT'] header in order to identify the web browser from where a web request originates.

开发一个网站,手机浏览器是不是一个完全不同的世界。但是你要记住以下限制:

Developing a web site for a mobile browser is not a totally different world. However you have to keep in mind the following constraints:


  • 屏幕尺寸:不仅你的屏幕房地产是小,但大小和方向变化不同移动设备之间大量

  • Screen Size: Not only your screen real-estate is smaller, but sizes and orientations vary a lot between different mobile devices.

Flash支持:。大多数移动浏览器不支持flash

Flash Support: The majority of mobile browsers do not support flash.

JavaScript的支持:比闪光灯更支持移动浏览器的JavaScript,尤其是在现代移动电话和PDA

JavaScript Support: JavaScript is much more supported than Flash on mobile browsers, especially in modern mobile phones and PDAs.

渲染性能:复杂的页面需要更长的时间呈现在移动浏览器。一般来说,如果你决定使用JavaScript,DOM的操纵通过JavaScript应该是最小的。

Rendering Performance: Complex pages take longer to get rendered in mobile browsers. In general if you decided to use JavaScript, manipulation of the DOM through JavaScript should be minimal.

移动带宽:记住要保持图像压缩尽可能,和来缩小所有的HTML,CSS和JavaScript。

Mobile Bandwidth: Remember to keep images compressed as much as possible, and to minify all the HTML, CSS and JavaScript.

这篇关于我将如何确定,如果一个网站从移动浏览器起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 18:54