Have IfMobile="True" for iPad?

Jul 12, 2012 at 7:18 PM

Is there any way to make IfMobile="True" for iPad? Thanks.

Coordinator
Jul 12, 2012 at 7:35 PM

Currently not as the used detection does not see an ipad as mobile.
You could use the user agent though to detect all ipads.
IfUserAgentString="ipad"

Jul 12, 2012 at 7:57 PM

Always showing true in any browser

Coordinator
Jul 12, 2012 at 8:04 PM

Ok, I'll have a look at it tomorrow and let you know..

Jul 12, 2012 at 8:05 PM

Thanks for the quick replies

Coordinator
Jul 12, 2012 at 10:13 PM

I tested it and it does seem to work for me.

I added this:

<fortyfingers:STYLEHELPER ID="SH1" IfUserAgentString="ipad" AddCssFile="[S]/LoadCss/Red.css" runat="server" />

And the CSS file is only loaded if I choose an ipas user agent..

What did you test (and on what DNN version?)

Jul 12, 2012 at 10:31 PM

DNN 6.1.5 trying to use it with AddJsFile

Coordinator
Jul 12, 2012 at 10:59 PM

Strange.. (I'm testing on 5.6.3, but that should not make a difference)
Could you post what you have in your skin exactly?
What if you try my example (using a CSS file)?

BTW, I just tested and you could use this to detect more tablets then only the ipad
<fortyfingers:STYLEHELPER ID="SH1" IfUserAgentString="ipad|android|playbook|silk|kindle,!mobile" AddCssFile="[S]/LoadCss/Red.css" runat="server" />

Jul 12, 2012 at 11:20 PM

Just tried this and it's loading the 

<fortyfingers:STYLEHELPER ID="JSHelper" IfMobile="True" AddJsFile="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js" runat="server" /> <fortyfingers:STYLEHELPER ID="SH1" IfUserAgentString="ipad|android|playbook|silk|kindle,!mobile" AddJsFile="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js" runat="server" />

I tried with and without the top one and also with and without the !mobile, not sure why you had that in

Jul 12, 2012 at 11:23 PM

<fortyfingers:STYLEHELPER ID="JSHelper" IfMobile="True" AddJsFile="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js" runat="server" />

This works fine by itself for mobile, but ipad doesn't display as a mobile browser so it doesn't work in that case.

Coordinator
Jul 12, 2012 at 11:36 PM
Edited Jul 12, 2012 at 11:37 PM

The !mobile is only needed if you only want to address tablets, not Mobile.

You can download the 02.06.01 Beta version I just added and try the new attribute DetectMobileIncludeTablet and set it to true in combination with IfMobile="True".
This attribute adjusts the regex used as described on the detectmobilebrowser.com/about page.
But I don't believe that way all tablets will be detected (most should be)...

Example:
<fortyfingers:STYLEHELPER ID="JSHelper" IfMobile="True" DetectMobileIncludeTablet="True" AddJsFile="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js" runat="server" />

You can also set the regex used by detectmobilebrowser.com (DetectMobileRegex1 attribute) and add some extra user agent identifiers..

I might add other detection scripts in later stage (if you have any suggestions, let me know)

Jul 13, 2012 at 1:28 AM

That appears to be working great! Thanks