Archived topic
How to display an Element just on desktop devices??
15 replies · Started by Patricia on September 19, 2018
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!
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>
mmm it doesn't work
I edited the code above, can you try that.
didn't work either.
maybe specifying the max/min width? (no idea)
Can you retry the code above again - i made a typo...
it still doesn't :(
I asked them if they can take care of that
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
thanks David <3
You're welcome, sorry i couldn't fix it :) let me know
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
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.
thanks, i will let them know
Fingers crossed :)
the just told they fixed it so it will be shown just on desktop
thanks a lot :)