Guy Parry

Q: Script to detect ipad browser in iweb?

I've dug into the iweb package contents (and given myself permission to tamper with them) and I'm now looking for the script used to detect browser version

 

I'm particularly looking for the detection of an ipad and would like to force it to the full site rather than mobile

 

I can see the file iWebSite.js which references iphone/mobilesafari. Is this the right script to alter? What needs to be changed to direct an ipad browser to the full 'slideshow' of an album?

 

Any pointers much appreciated. I'm hoping that despite any announcements iWeb on MMe/iCloud will be around for a while ;-)

iWeb '08, Mac OS X (10.6.7)

Posted on Jun 12, 2011 2:02 PM

Close

Q: Script to detect ipad browser in iweb?

  • All replies
  • Helpful answers

  • by Cyclosaurus,

    Cyclosaurus Cyclosaurus Jun 12, 2011 6:19 PM in response to Guy Parry
    Level 6 (12,915 points)
    Jun 12, 2011 6:19 PM in response to Guy Parry
    I can see the file iWebSite.js which references iphone/mobilesafari. Is this the right script to alter?

     

    yes, however there s no variable for ipad so you have to add it

    search for: var isiPhone

    add var isiPad after that.

     

    then add code to detect ipad user agent.

    search for:  isiPhone=(ua.indexOf("mobile/")!=-1);

     

    then replace it with:

     

                    isiPhone = (ua.indexOf("mobile/") != -1 && ua.indexOf("iphone") != -1 ua.indexOf("ipad") == -1);

                    isiPad = (ua.indexOf("mobile/") != -1 && ua.indexOf("iphone") == -1 ua.indexOf("ipad") != -1);

  • by Cyclosaurus,Solvedanswer

    Cyclosaurus Cyclosaurus Jun 12, 2011 7:30 PM in response to Cyclosaurus
    Level 6 (12,915 points)
    Jun 12, 2011 7:30 PM in response to Cyclosaurus

    correction, this posting system munched up things:

     

                   isiPhone = (ua.indexOf("mobile/") != -1 && ua.indexOf("iphone") != -1 && ua.indexOf("ipad") == -1);

                    isiPad = (ua.indexOf("mobile/") != -1 && ua.indexOf("iphone") == -1 && ua.indexOf("ipad") != -1);

  • by Wyodor,Helpful

    Wyodor Wyodor Jun 13, 2011 12:08 AM in response to Guy Parry
    Level 6 (19,753 points)
    Jun 13, 2011 12:08 AM in response to Guy Parry

    Paste this in a HTML Snippet :

     

    <script language="JavaScript" type="text/javascript">
    <!--
    
    var agent=navigator.userAgent.toLowerCase();
    
    // iPhone and iPod touch are both 'iphone'
    
    var is_iphone = (agent.indexOf('iphone')!=-1);
    var is_ipad = (agent.indexOf('ipad')!=-1);
    
    alert("iphone = " + is_iphone + "\nipad = " + is_ipad );
    
    if (is_iphone || is_ipad) {
        top.window.location = "http://www.mydomain.com";
        }
    
    // -->
    </script
    

     

    Found with this search : detect mobile browser

     

    More Made for iPad with iWeb pages here: http://www.wyodor.net/mfi/

  • by Guy Parry,

    Guy Parry Guy Parry Jun 13, 2011 2:19 AM in response to Cyclosaurus
    Level 1 (0 points)
    Jun 13, 2011 2:19 AM in response to Cyclosaurus

    Thank you so much for this. I've made the edits to the .js and if the ipad is in portrait orientation I get what I'm looking for but not if it's in landscape position!

     

    I'll keep plugging around and see what I can find about orientation setting and maybe post a separate question on that. Thanks again.

  • by Wyodor,Helpful

    Wyodor Wyodor Jun 13, 2011 2:49 AM in response to Guy Parry
    Level 6 (19,753 points)
    Jun 13, 2011 2:49 AM in response to Guy Parry

    Have a look here : http://www.google.com/search?q=ipad+css+orientation

     

    Here's a non-iWeb page for iPad to try : http://www.wyodor.net/Centered/ipad.html

  • by Guy Parry,

    Guy Parry Guy Parry Jun 13, 2011 4:05 AM in response to Wyodor
    Level 1 (0 points)
    Jun 13, 2011 4:05 AM in response to Wyodor

    This is all great stuff! Initially I just wanted proper sized pictures for an iweb slideshow on ipad and now I'm inspired to adapt the site for ipad screen orientation! :-)

     

    Thank you

  • by Thomas Schroeder,

    Thomas Schroeder Thomas Schroeder Mar 7, 2015 2:13 PM in response to Cyclosaurus
    Level 1 (5 points)
    Mar 7, 2015 2:13 PM in response to Cyclosaurus

    You sir, have made my day

    No, really. This has been bugging me for our photo site like forever and I finally managed to fix this for viewing on an iPad with your help. Thank you, thank you, thank you