jeger003 Posted July 22, 2009 Share Posted July 22, 2009 hi everyone, i am trying to create a code for my site to detect mobile phone users. it would redirect them to a replica of my site like mobile.mysite.com and it would be completely text.... my issue is detecting the users mobile device..i used many scripts and none have done the job or even detected the mobile phones i want to start out by if ( $_SERVER['HTTP_USER_AGENT'] --something like "IS LIKE"-- iphone) cause i cant do if ($_SERVER['HTTP_USER_AGENT'] = iphone) that would mean the entire user agent is "iphone" which it wont be i would appreciate help LINKS TO TUTORIALS WOULD HELP!! Quote Link to comment Share on other sites More sharing options...
haku Posted July 22, 2009 Share Posted July 22, 2009 You can use CSS instead, and serve up a different stylesheet just for mobile devices. In this manner, you don't have to do a redirect, duplicate content, or even create a different site, you just re-style the content. A normal stylesheet links like this: <link rel="stylesheet" src="style.css" type="text/css" /> You can add extra stylesheets, and use the 'media' attribute: <link rel="stylesheet" src="style.css" type="text/css" media="screen" /> // for computers <link rel="stylesheet" src="style.css" type="text/css" media="handheld" /> // for cellphones Quote Link to comment Share on other sites More sharing options...
jeger003 Posted July 22, 2009 Author Share Posted July 22, 2009 my site consists on many images that are "drag and dropped" on the page......not cssed onto it...how do i get around that? and as for "media=handheld" is the page going to detect it as a handheld device and use the appropriate style sheet? thank you haku Quote Link to comment Share on other sites More sharing options...
jeger003 Posted July 22, 2009 Author Share Posted July 22, 2009 ok, im testing out what you've recommended but im not really sure how it supposed to work... i create two of the same style sheets? or do i create two styles one for PC one for Mobile? how do i specify it on a font or something i.e <style=PC-font> word here </style> how do i use the mobile-font on the same thing? and as for the image part......well i have an image at the top....that shrinks when loaded in the browser and it really expands and displaces everything else Quote Link to comment Share on other sites More sharing options...
haku Posted July 22, 2009 Share Posted July 22, 2009 my site consists on many images that are "drag and dropped" on the page......not cssed onto it...how do i get around that? Not sure what you mean by this. i create two of the same style sheets? or do i create two styles one for PC one for Mobile? Two different sheets - one for PC and one for Mobile. The device itself will know whether it is a PC or a mobile, and will (or at least should) only download the appropriate stylesheet. To specify a font, place it in the appropriate stylesheet. You don't need any special declaration. and as for the image part......well i have an image at the top....that shrinks when loaded in the browser and it really expands and displaces everything else Set it as a background image in your CSS for the PC stylesheet. In the mobile stylesheet, specify a different image for the background image (one that is made for a phone-sized screen). Quote Link to comment Share on other sites More sharing options...
jeger003 Posted July 22, 2009 Author Share Posted July 22, 2009 this is an awesome IDEA!!!! works great the other thing i wanted to do was to actually redirect mobile users to a different url like mobile.sitename.com because i wanted to create a page for mobile users to be able to just make purchases....it wouldn't have any of the texts or images......just a few "buy now" buttons any idea how i can go about that? Quote Link to comment Share on other sites More sharing options...
jeger003 Posted July 22, 2009 Author Share Posted July 22, 2009 can anyone help me with this? please Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.