JavaScript Responsive Ads based on Screen Resolution

Find best Web Development tips and Tricks.
Post Reply
arnlweb
Site Admin
Posts: 95
Joined: Wed Jun 22, 2016 1:28 pm
Location: India
Contact:

JavaScript Responsive Ads based on Screen Resolution

Post by arnlweb » Tue Sep 05, 2017 7:46 am

Here is the JavaScript Responsive Ads code, it will show your ads based on screen resolution.

Code: Select all

<script> var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; if (width >= 1024) { document.write('<scr'+'ipt type="text/javascript" src="//liveadexchanger.com/a/display.php?r=XXXXX"></scr'+'ipt>'); } else if ((width < 1024) && (width > 600)) { document.write('<scr'+'ipt type="text/javascript" src="//liveadexchanger.com/a/display.php?r=CCCCCC"></scr'+'ipt>'); } else { document.write('<scr'+'ipt type="text/javascript" src="//liveadexchanger.com/a/display.php?r=DDDDD"></scr'+'ipt>'); } </script>

Post Reply