header.php different desktop and mobile version

Posted in: Newsmag
Post count: 44

how can I make a javascript code that I included in header.php is only in desktop version and NOT in the mobile version?
I have a problem with the mobile version:
I put the code of google double click to manage banners, but the mobile version I opened the fraudulent banner in mobile connection.

<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/92719100/300x250', [300, 250], 'div-gpt-ad-1438xx-0').addService(googletag.pubads());
googletag.defineSlot('/92719100/728x90moviemedia', [728, 90], 'div-gpt-ad-1438xx-1').addService(googletag.pubads());
googletag.defineSlot('/92719100/800x300a', [800, 300], 'div-gpt-ad-1438xx-2').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>

I need this code is not running on the mobile versions.

thank you 🙂

Post count: 6535

Hi

To deactivate the code from mobile devices you will need a script which detects the screen’s width and deactivate the code according by device’s size. This is a complex task and if you don’t know how to do it yourself my advice is to look for a freelancer from sites like http://studio.envato.com/ to do it for you as we cannot offer any custom work at this moment, sorry.

Thanks for the message!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newsmag’ is closed to new topics and replies.