WXforum.net
May 23, 2013, 05:53:27 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
Members: 6619  •  Posts: 178704  •  Topics: 18130
Please welcome moranbahweather, our newest member.
Welcome to the the new hosting for WXforum.net.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Help with HTML script for mobile web option  (Read 1482 times)
0 Members and 1 Guest are viewing this topic.
smorris
Forecaster
*****
Offline Offline

Posts: 453



WWW
« on: September 22, 2011, 11:41:46 PM »

Below is a script from my web page template that detects mobile devices and redirect them to the ipwx_Cam.html page

Does anyone know how to interpret this script? I'd like to exclude the iPad from being redirected to the mobile version, but can't make heads or tails out of it, and I don't want to just start trimming it randomly.

Thanks,
Steve

Quote
<!-- Begin Script -->

<script type="text/javascript">
(function(){var c=navigator.userAgent,a=window.location,d=document.cookie,b=a.href;if(c.match(/iP(od|hone)/i)||c.match(/Android/i))if(d.indexOf("iphone_redirect=false")<0)a.href="ipwx_Cam.html";if(c.match(/iPad/i))if(d.indexOf("iphone_redirect=false")<0)a.href="ipwx_Cam.html";else if(b.indexOf("ipad")==-1){b+=b.indexOf("?")>-1?"&ipad":"?ipad";a.href=b}})();
</script>

<!-- End Script -->
« Last Edit: September 22, 2011, 11:43:28 PM by smorris » Logged

Steve - Avon, Ohio
Davis Vantage Pro2 Plus w/FARS, Leaf & Soil Station

CWOP • WU • AWEKAS • CoCoRaHS • Skywarn • MWWN • UK Met • PWS • WeatherBug • TwitterFacebook
xykotik
DonkeyTailWX DW6891
Forecaster
*****
Offline Offline

Posts: 691


I'll deal with it tomorrow


WWW
« Reply #1 on: September 23, 2011, 07:30:59 AM »

I remember an article in PC Mag about an app that would change your browser/client ident to "Mozilla" or "MSIE" or whatever you like so an iPad wouldn't get stuck at a mobi redirect.  I'm sorry I don't remember which issue that was, but probably one of those "100 best" specials.

Another option I can think of is a link to "break out of this mobi page" that goes back to a non-smart page, if it is for users that don't have such a special app as mentioned above.
Logged



Facit solem suum oriri super bonos et malos et pluit super iustos et iniustos.

Springtime in Seattle...  March comes in like a lion and out like a wet lion.
CNYWeather
Forecaster
*****
Offline Offline

Posts: 1386



WWW
« Reply #2 on: September 23, 2011, 07:49:08 AM »

Check out this thread: http://www.wxforum.net/index.php?topic=10372.0

Using some code from http://detectmobilebrowsers.mobi/ you can exclude iPads, iPods, or really what ever your like.
Logged

smorris
Forecaster
*****
Offline Offline

Posts: 453



WWW
« Reply #3 on: September 23, 2011, 08:49:17 AM »

Another option I can think of is a link to "break out of this mobi page" that goes back to a non-smart page,

That's what I was thinking, as well, but couldn't direct it back to the "real" page without it going through the detection again and coming back to the mobile version.

I could always do away with the automatic detection anyway and just go with avon-weather.com/m or m.avon-weather.com. But since my iPhone, iPad and desktop all share a common favorites list, I'd like to just have one entry to cover all three.



Check out this thread: http://www.wxforum.net/index.php?topic=10372.0

Using some code from http://detectmobilebrowsers.mobi/ you can exclude iPads, iPods, or really what ever your like.

Cool! Thanks for the great info. I'll see if I can tweak things to get my page to wor.

Thanks guys,
Steve
Logged

Steve - Avon, Ohio
Davis Vantage Pro2 Plus w/FARS, Leaf & Soil Station

CWOP • WU • AWEKAS • CoCoRaHS • Skywarn • MWWN • UK Met • PWS • WeatherBug • TwitterFacebook
CNYWeather
Forecaster
*****
Offline Offline

Posts: 1386



WWW
« Reply #4 on: September 23, 2011, 09:35:36 AM »

The detectmobilebrowsers works like a charm. I had it on my site
and people really liked it. I did however take it off because I have to tweak the code
a bit, because some tablets were getting redirected to the mobile site and I had a few complaints.

that can be easily fixed I'm sure. Early winter project for me.

Logged

smorris
Forecaster
*****
Offline Offline

Posts: 453



WWW
« Reply #5 on: September 23, 2011, 03:11:07 PM »

Got it working. Thanks for the input here and for the folks on MacWeather.com. One of those guys tweaked the existing script so the iPad is now excluded before I even got to trying detectmobilebrowsers.mobi. There's a Flash moon phase image that doesn't work, but I still prefer the web version on the iPad to the mobile version.

Quote
<!-- Begin Script -->

<script type="text/javascript">
(function(){var c=navigator.userAgent,a=window.location,d=document.cookie,b=a.href;
if(c.match(/iP(od|hone)/i)||c.match(/Android/i))if(d.indexOf("iphone_redirect=false")<0)a.href="ipwx_Cam.html";
})();
</script>

<!-- End Script -->

Thanks again for all the help. Even though I used another solution, I found additional HTML resources that will come in handy in the future.
Steve
Logged

Steve - Avon, Ohio
Davis Vantage Pro2 Plus w/FARS, Leaf & Soil Station

CWOP • WU • AWEKAS • CoCoRaHS • Skywarn • MWWN • UK Met • PWS • WeatherBug • TwitterFacebook
xykotik
DonkeyTailWX DW6891
Forecaster
*****
Offline Offline

Posts: 691


I'll deal with it tomorrow


WWW
« Reply #6 on: September 23, 2011, 10:53:11 PM »

Thank you for posting the solution.  Applause It's the "right" thing to do, even if it came from somewhere else.

Doesn't it bite when you read thread after thread from your long list of search results and just get "it's working now" without the payoff?
Logged



Facit solem suum oriri super bonos et malos et pluit super iustos et iniustos.

Springtime in Seattle...  March comes in like a lion and out like a wet lion.
smorris
Forecaster
*****
Offline Offline

Posts: 453



WWW
« Reply #7 on: September 24, 2011, 12:42:11 AM »

Thanks. I always try to reply with how I fixed something or document whatever I'm trying to do. I've moderated car and scooter forums for years, and am known as the guy to over-document everything. Smile
Logged

Steve - Avon, Ohio
Davis Vantage Pro2 Plus w/FARS, Leaf & Soil Station

CWOP • WU • AWEKAS • CoCoRaHS • Skywarn • MWWN • UK Met • PWS • WeatherBug • TwitterFacebook
xykotik
DonkeyTailWX DW6891
Forecaster
*****
Offline Offline

Posts: 691


I'll deal with it tomorrow


WWW
« Reply #8 on: September 24, 2011, 09:19:48 AM »

My nickname at work is "Doc"
Logged



Facit solem suum oriri super bonos et malos et pluit super iustos et iniustos.

Springtime in Seattle...  March comes in like a lion and out like a wet lion.
smorris
Forecaster
*****
Offline Offline

Posts: 453



WWW
« Reply #9 on: September 24, 2011, 10:54:28 AM »

My nickname at work is "Doc"

 Very Happy
Logged

Steve - Avon, Ohio
Davis Vantage Pro2 Plus w/FARS, Leaf & Soil Station

CWOP • WU • AWEKAS • CoCoRaHS • Skywarn • MWWN • UK Met • PWS • WeatherBug • TwitterFacebook
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.101 seconds with 19 queries.