0

I need to display different information to an iPhone user, as they cant display flash. So therefore display a jpeg for example for anyone using an iPhone, and any other device can see the flash content.

I assume the best way to go about this would be to use either JavaScript or jQuery, using the http header information. However I don't know where to start, does anyone have any ideas?

Ideally, I don't want to replace it an error if the person doesn't have JavaScript, as I don't want the iPhone user to think they are missing out.

Kara
  • 6,115
  • 16
  • 50
  • 57
treasureireland
  • 87
  • 2
  • 3
  • 10
  • 1
    possible duplicate of [fallback image for flash object](http://stackoverflow.com/questions/5801615/fallback-image-for-flash-object) – Quentin Jul 04 '12 at 09:38
  • You should be detecting Flash support, not singling out particular devices. Then you don't care about the device or capability of the UA. – RobG Jul 04 '12 at 09:39

2 Answers2

0

You can define navigator.userAgent.match(/iPhone/i) which checks if the webpage is opened in iphone or other device. Make it a config variable or define it globally so that you access it all over the script. Then you can easily put the check condition to show iphone specific content.This will return true for iphone and false in rest devices. I guess this is what you were looking. Hope this helps.

user850234
  • 3,373
  • 15
  • 49
  • 83
0

Targeting specific devices is generally not considered good practice because you can only cater for known devices at the point you are coding, things may break in future. You can test the user agent in JS but this isn't a good approach. For an example, see:-

http://www.htmlgoodies.com/beyond/webmaster/toolbox/article.php/3888106/How-Can-I-Detect-the-iPhone--iPads-User-Agent.htm

...better practice is to test for support for a given technology/hardware/function etc. To test for Flash, take a look at these answers:-

How can I detect if Flash is installed and if not, display a hidden div that informs the user?

Perhaps also worth mentioning that CSS is a powerful tool for displaying diffent content for different screen sizes. Google for 'javascript media queries' and you will find plenty of information. Here's an introduction for a start:-

http://css-tricks.com/css-media-queries/

Community
  • 1
  • 1
Purpletoucan
  • 6,472
  • 2
  • 21
  • 28