Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Blogger (blogspot) not mobile conditional format

I would like to load javascript files only on Desktop version of my Google blogspot (blogger.com) since I need a light version of my blog for mobile.

I came through followings, but not working

<b:if cond != 'data:blog.isMobile'>;
<b:if cond = !'data:blog.isMobile'>;
<b:if cond = '!data:blog.isMobile'>;
<b:if cond='data:blog.pageType !== "data:blog.isMobile">

How can I write "is Not Mobile" conditional in Google blogspot? Thanks in advance for all answers.

================================================================================

Update: I'm using following code at the moment and it's working but better ideas are welcome

<b:if cond='data:blog.isMobile'>

<b:else/>
    //I include javascript files here and they only appear on desktop version
</b:if>
like image 324
Optimizr Avatar asked Mar 21 '14 17:03

Optimizr


2 Answers

You can use true or false statements in blogger conditional tags in this case. This is the best way ;)

<b:if cond='data:blog.isMobile == &quot;false&quot;'>
//Contents inside this, will only appear in Desktop version.
</b:if>

Edit #1:

This will work only if you have enabled mobile template, and set it to custom.

enter image description here

enter image description here

And it does work on Chrome's mobile emulator. (will be redirected to mobile version if visiting from a mobile device or with an emulator that reflects a mobile Browser User Agent. it will add ?m=1 at the end of the URL)

enter image description here

Hope this helps.

like image 89
Muhammed Aslam C Avatar answered Sep 22 '22 19:09

Muhammed Aslam C


i've found a useful conditional tag to display only on mobile view recently. this conditional tag worked even i didn't activate mobile template.

<b:if cond='data:blog.isMobileRequest == &quot;true&quot;'>
<!-- showed only if browser request as a mobile -->
<b:else/>
<!-- showed if browser not requesting as a mobile device-->
</b:if>

Try use this with my example: in this example, thumbnail image removed when mobile request value is true and displaying thumbnail if not requested.

<b:if cond='data:blog.isMobileRequest == &quot;true&quot;'>
            <div>
              <div class='item-title'><a expr:href='data:post.href' expr:title='data:post.snippet'><data:post.title/></a></div>
            </div>
<b:else/>
            <div class='item-thumbnail-only'>
              <b:if cond='data:post.thumbnail'>
                <div class='item-thumbnail'>
                  <a expr:href='data:post.href' expr:title='data:post.snippet' target='_blank'>
                    <img border='0' expr:alt='data:post.title' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
                  </a>
                </div>
              </b:if>
              <div class='item-title'><a expr:href='data:post.href' expr:title='data:post.snippet'><data:post.title/></a></div>
            </div>
</b:if>

you can find this conditional tag value in view-source of your blogspot page.

data:blog.isMobileRequest is a condition wich listening value of m= query on address bar.

web address followed with m=1 it mean isMobileRequest: true;

image 1

and if not followed with m=1 or followed with m=0 it mean isMobileRequest: false;

image 2

like image 30
Phate Holloway Avatar answered Sep 21 '22 19:09

Phate Holloway