Skip to content

Instantly share code, notes, and snippets.

@ahmedash95
Created January 1, 2017 14:28
Show Gist options
  • Save ahmedash95/9aee81e733821b38aff71413a64a3359 to your computer and use it in GitHub Desktop.
Save ahmedash95/9aee81e733821b38aff71413a64a3359 to your computer and use it in GitHub Desktop.
<script>
function addMWebAd() {
var title = "<p style='margin-top: -25px;position: absolute;z-index: 999999;background-color: #f4f4f4;'>FB Ad</p>";
var txt1='<script id="facebook-jssdk" src="https://connect.facebook.net/en_US/sdk/xfbml.ad.js#xfbml=1&version=v2.5&appId=$appID$">'+
'</scr'+'ipt>';
var txt3='<script>'+
'window.fbAsyncInit = function() {'+
'FB.Event.subscribe('+
'\'ad.loaded\','+
'function(placementID) {'+
'console.log(\'ad loaded\');'+
'});'+
'FB.Event.subscribe('+
'\'ad.error\','+
'function(errorCode, errorMessage, placementID) {'+
'console.log(\'ad error \' + errorCode + \': \' + errorMessage);'+
'});'+
'};'+
'</scr'+'ipt>';
var txt2='<div id="fb-root">'+
'</div>'+
'<fb:'+'ad placementid="$placement_id$" format="300x250" testmode="false">'+
'</fb:'+'ad>';
var doc_mweb = document.getElementById('iframe_mweb').contentWindow.document;
doc_mweb.open();
doc_mweb.write('<html><head>'+txt1+'</head><body style="padding:15px">'+title+txt3+txt2+'</body></html>');
doc_mweb.close();
}
addMWebAd();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment