473,721 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect the client computer is using PC Browser / Mobile Browser?

Thanks
Jun 2 '08 #1
8 6528
NC
On May 13, 8:01 pm, "George" <@wrote:
>
How to detect the client computer is using PC Browser / Mobile
Browser?
By analyzing the content of $_SERVER["HTTP_USER_AGEN T"], which,
needless to say, can be missing or configured to say anything...

Cheers,
NC

Jun 2 '08 #2
On May 14, 4:01 am, "George" <@wrote:
Thanks
You could try looking at the user agent string and analysing that to
try and guess the browser, but in all honesty there's no 100% reliable
way to determine what browser the user is using. The user agent
string is sent by the browser but there's nothing preventing the
browser sending one that identifies it as a different browser from
what it actually is.

Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served. If you're attempting to get around browser rendering issues
(ie IE6 and its brain damaged CSS), then conditional comments in the
HTML is a better approach. Only IE recognises them, other browsers
ignore them, so you can use them to load IE specific stylesheets and
javascript to work around that browser's flaws.

Don't try using user agent analysis to lock certain browsers out of
your site! You're annoying users and driving them away, and those
determined enough and knowledgeable enough to spoof the user agent
string can get around any blocks you might put up any way.
Jun 2 '08 #3
On May 14, 6:01 am, "George" <@wrote:
Thanks
Hi,

You can see
http://techpatterns.com/downloads/ph..._detection.php

and

http://www.hostpc.com/community/showthread.php?t=1599

also

Think about this code and enjoy :)

<?php
//If principal is using a Palm, then set it for presentation changes,
etc.

$string = $_SERVER['HTTP_USER_AGEN T'];
$substring = 'Palm';
$pos = 0;
$pos = strpos($string, $substring, $pos);
if ($pos =='')
{
$isPalm="0";
}
else {
$isPalm="1";
}
?>

Jun 2 '08 #4
On 14 May, 09:16, Gordon <gordon.mc...@n tlworld.comwrot e:
Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served.
I think that the answer to this question is in the OP's original
question.

As with the mobile Google search page and lots of other pages, web
site designers recognise that viewing a page on a tiny mobile device's
screen is a very different experience to viewing it on a "standard"
computer monitor, quite apart from the connection speed differences
that are still commonly encountered between the 2 platforms.

I for one am very pleased that designers take this into account.

Do you build all your sites to look great on a 2.8inch screen and then
have vast areas of nothing on a PC monitor?
Jun 2 '08 #5
PHP-Arabia a écrit :
Think about this code and enjoy :)

<?php
//If principal is using a Palm, then set it for presentation changes,
etc.

$string = $_SERVER['HTTP_USER_AGEN T'];
$substring = 'Palm';
$pos = 0;
$pos = strpos($string, $substring, $pos);
if ($pos =='')
{
$isPalm="0";
}
else {
$isPalm="1";
}
?>
<?php
$isPalm = (strpos($_SERVE R['HTTP_USER_AGEN T'], 'Palm') !== false);
?>

$isPalm is false/true.
--
Guillaume
Jun 2 '08 #6
On May 14, 12:47 pm, Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 14 May, 09:16, Gordon <gordon.mc...@n tlworld.comwrot e:Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served.

I think that the answer to this question is in the OP's original
question.

As with the mobile Google search page and lots of other pages, web
site designers recognise that viewing a page on a tiny mobile device's
screen is a very different experience to viewing it on a "standard"
computer monitor, quite apart from the connection speed differences
that are still commonly encountered between the 2 platforms.

I for one am very pleased that designers take this into account.

Do you build all your sites to look great on a 2.8inch screen and then
have vast areas of nothing on a PC monitor?
Could that not be accomplished with a stylesheet for mobile users
though? On reflection I can see that sending a mobile browser less
content is obviously a good thing given that they tend to have limited
bandwidth, but with clever site design the stylesheet should be able
to accomplish that.

I didn't fully appreciate the OP's question as he'd posted it into the
title and left his body more or less blank.
Jun 2 '08 #7
George escribiĆ³:
Thanks
You're welcome.

Oh, come on, don't write the whole question in the subject xD

Have a look at get_browser():

http://php.net/function.get_browser
http://browsers.garykeith.com/downloads.asp

You'll probably need to download the browser database
(lite_php_brows cap.ini should be okay) but it's far more accurate that
any home made browser sniffing of your own. Just fetch the
"isMobileDevice " property and let others do the research.

--
-- http://alvaro.es - Ɓlvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programaciĆ³n web: http://bits.demogracia.com
-- Mi web de humor al baƱo MarĆ*a: http://www.demogracia.com
--
Jun 2 '08 #8
On 14 May, 15:37, Gordon <gordon.mc...@n tlworld.comwrot e:
On May 14, 12:47 pm, Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 14 May, 09:16, Gordon <gordon.mc...@n tlworld.comwrot e:Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served.
I think that the answer to this question is in the OP's original
question.
As with the mobile Google search page and lots of other pages, web
site designers recognise that viewing a page on a tiny mobile device's
screen is a very different experience to viewing it on a "standard"
computer monitor, quite apart from the connection speed differences
that are still commonly encountered between the 2 platforms.
I for one am very pleased that designers take this into account.
Do you build all your sites to look great on a 2.8inch screen and then
have vast areas of nothing on a PC monitor?

Could that not be accomplished with a stylesheet for mobile users
though? On reflection I can see that sending a mobile browser less
content is obviously a good thing given that they tend to have limited
bandwidth, but with clever site design the stylesheet should be able
to accomplish that.
I don't see how the stylesheet could limit the amount of content being
sent.
Jun 2 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3353
by: ripken95 | last post by:
I connect to the internet through ADSL. I want to write the web page which can detect the connection status with javascript. This detection is like the signal detection in the mobile phone. If the signal is weak, the status may have one squares or zero on the phone. How could I do if I want to detect the status of the network? Thx and Best Regards.
2
1571
by: Joe Abou Jaoude | last post by:
hi, in my web app, I need to detect if a client computer is a Mac. i thought to use Request.Browser.Platform, however i don't have a Mac to test on it, so i have no idea what I'll get in result. can anyone help ? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
1
3199
by: onewebclick | last post by:
Is there a way to detect a browser cache is full using javascript or HTML thorugh a web page and inform the user to clear the cache to improve performance of the website. It looks like google's gmail use to detect and warn "Gmail says my browser's cache is full" http://gmail.google.com/support/bin/answer.py?answer=14106 then there should be a way to do it if google can do it. Any thoughts ?
3
9133
by: Sara | last post by:
HI, I want to code a program to detect GSM mobile (any kind) which connected through serial port to computer and then be able to send SMS through this mobile phone to other mobile phones, could anyone help me and guide me, I wrote a program which could open COM port but still couldn't detect mobile phone and send SMS through it. I searched internet and I didn't find right answer to my question. please if anyone could guide me. the...
6
5238
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
4
7010
by: Sara | last post by:
Hi I want to code a program which could send SMS through web page to mobile phone, but because there is no Service here such as SMPP , therefore I have GSM mobile phone which connected directly to the server which run these aspx pages. now my question is 1- how to detect this mobile phone which connected through serial ports 2- how I could send SMS through this mobile to other mobile devices, if anyone has any suggestion please help me
11
4125
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have an aplication web asp.net 2.0 and I am Trying to detect the close event in browser, which is the best performance for do this ? What's up with Alt+F4, Refresh, user clicks X, etc ? Thanks. -- http://www.alhambra-eidos.es/web2005/index.html www.kiquenet.net
22
2934
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created using Perl on the backend, with Javascript providing limited frontend functionality. As an example, an expanding tree would be fully populated on the server-side and then presented to the browser, with Javascript and CSS being used to vary the...
1
4683
by: s3raph | last post by:
Hi, I'm having trouble detecting the client machine connection lost when the client physically pushes the power or restart button on their computer. Using the code from Plater in the following thread: http://bytes.com/topic/net/answers/828133-c-net-detecting-socket-closed I have managed to detect disconnect by the client when the client window form is closed, but if the client computer switches off or powers off, it doesn't detect a...
0
8736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9227
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9143
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5992
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3202
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2137
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.