Skip to content

Instantly share code, notes, and snippets.

@pricejn2
Last active November 15, 2024 03:24
Show Gist options
  • Save pricejn2/4ffd0b928327fe8b8edcadb94bedc2dc to your computer and use it in GitHub Desktop.
Save pricejn2/4ffd0b928327fe8b8edcadb94bedc2dc to your computer and use it in GitHub Desktop.
responsive ad unit with revive ad server
<div id="revive-responsive-top" style="display: block; text-align: center;">
<script type="text/javascript">
adUnit = document.getElementById("revive-responsive-top");
adWidth = adUnit.offsetWidth;
if ( adWidth >= 728 ) {
/* Leaderboard 728x90 */
adUnit.innerHTML = '<ins data-revive-zoneid="3" data-revive-id="4689b54ec658f530f3250f4124e7f1ea"></ins>';
} else {
/* Mobile Banner 320x50 */
adUnit.innerHTML = '<ins data-revive-zoneid="5" data-revive-id="4689b54ec658f530f3250f4124e7f1ea"></ins>';
}
</script>
<script async src="//revive.example.com/www/delivery/asyncjs.php"></script>
</div>
@vpotap
Copy link

vpotap commented Sep 14, 2017

can use without direct link to parent id
var scriptTag = document.getElementsByTagName('script');
scriptTag = scriptTag[scriptTag.length - 1];
var adUnit = scriptTag.parentNode;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment