[Resolved] How to display an Element just on desktop devices??

Home Forums Support [Resolved] How to display an Element just on desktop devices??

Home Forums Support How to display an Element just on desktop devices??

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #680906
    Patricia

    Hi!

    Here again πŸ™‚

    I created an Element in order to show an ad widget inside the cointaner (bellow the header) of certain pages of the site.

    The thing is don’t want it to be shown on mobile because it takes too much space, but i don’t know how to do that because there’s no such option in the “Elements” tool.

    Could you help me on that?

    That’s the code for the ads

    <script type="text/javascript" src="https://img.lzrikate.com/ads/lz_loader.js?ver=1.3"></script>
    <div id="ads_KJDLQXXS0XCV"></div>
    <script language="javascript" type="text/javascript">
    var lz_url="https://play.lzrikate.com/red/zone.php?code=KJDLQXXS0XCV&a=&pubid=&lgid="+((new Date()).getTime() % 2147483648) + Math.random();
    var lz_target = "ads_KJDLQXXS0XCV";
    var lz_sync_mode=false;
    lz_loadads(lz_url ,lz_target,lz_sync_mode);
    </script>

    thanks!

    GeneratePress 2.1.4
    GP Premium 1.7.2
    #680916
    David
    Staff
    Customer Support

    Hi there,

    try adding the script like so:

    <script type="text/javascript" src="https://img.lzrikate.com/ads/lz_loader.js?ver=1.3"></script>
    <div id="ads_KJDLQXXS0XCV" class="hide-on-mobile"></div>
    <script language="javascript" type="text/javascript">
        var lz_url="https://play.lzrikate.com/red/zone.php?code=KJDLQXXS0XCV&a=&pubid=&lgid="+((new Date()).getTime() % 2147483648) + Math.random();
        var lz_target = "ads_KJDLQXXS0XCV";
        var lz_sync_mode=false;
        lz_loadads(lz_url ,lz_target,lz_sync_mode);
    </script>
    #680928
    Patricia

    mmm it doesn’t work

    #680939
    David
    Staff
    Customer Support

    I edited the code above, can you try that.

    #680958
    Patricia

    didn’t work either.

    maybe specifying the max/min width? (no idea)

    #680962
    David
    Staff
    Customer Support

    Can you retry the code above again – i made a typo…

    #680964
    Patricia

    it still doesn’t πŸ™

    I asked them if they can take care of that

    #680968
    David
    Staff
    Customer Support

    they should be able to provide a script that omits mobile from that, which is the right way of doing it. If no joy let me know and i’ll see what we can do with some Javascript

    #680969
    Patricia

    thanks David <3

    #680973
    David
    Staff
    Customer Support

    You’re welcome, sorry i couldn’t fix it πŸ™‚ let me know

    #681936
    Patricia

    hi!

    i have news on this.

    They told me they can create a code for desktop and another one for mobile… The thing is, how can I discriminate this with Element > Hook ? Wouldn’t it have the same problems?

    Thanks

    patricia

    #681964
    David
    Staff
    Customer Support

    It would be best if they added a !if_mobile() condition to the script, so it doesn’t execute if a mobile device is detected.

    #681965
    Patricia

    thanks, i will let them know

    #681969
    David
    Staff
    Customer Support

    Fingers crossed πŸ™‚

    #681971
    Patricia

    the just told they fixed it so it will be shown just on desktop

    thanks a lot πŸ™‚

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.