Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    432
    Thanks
    56
    Thanked 1 Time in 1 Post

    Detect if Mobile - Not Working for Windows Phone

    Hiya Everyone,

    Code:
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
    	var news = 'Our website has detected that you are using one of the following: \n'; 
    	news += '          • Android \n'; 
    	news += '          • Windows \n';
    	news += '          • webOS \n'; 
    	news += '          • iPhone \n';
    	news += '          • BlackBerry \n'; 
    	news += 'Or another commonly used system for handheld devices. This is just to note that our website is best viewed on these devices in landscape mode.';
    	
    	alert(news);
    };
    Using this which shows the message on my HTC One Android system, however this will not show on my friends Nokia Lumia 620 Windows system. I tried simply adding 'Windows' to the script, however this had no effect...

    I need my message to display for anyone on small devices, handholds. Any ideas?

    Best Regards,
    Tim
    Last edited by MrTIMarshall; 04-14-2014 at 02:19 AM.

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    wouldn't a more sensible way to do this be to test for window width, so you don't have to go guessing every operating system? Or to use media queries to make your site viewable in landscape or portrait?

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    432
    Thanks
    56
    Thanked 1 Time in 1 Post
    Quote Originally Posted by xelawho View Post
    wouldn't a more sensible way to do this be to test for window width, so you don't have to go guessing every operating system? Or to use media queries to make your site viewable in landscape or portrait?
    It is optimized for all resolutions, however on mobile devices, it is much better viewed in landscape mode. Here you can see my current page for yourself. I'll probably use a media query to show something different upon the scaling of the container ending up with space below it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •