I have this script:
<script type="text/javascript">
document.write("<script type='text\/javascript' src='"+(location.protocol == 'https:' ? 'https:' : 'http:') + "//n206adserv.com\/js/show_ads.js?pubId=20'><\/script>");
</script>
i want to run this script whenever some case in following script calls
<script>
function callMe(statusCode) {
var adEl = document.getElementById('adEl');
switch (statusCode) {
case 200:
adEl.innerHTML = '200 OK';
console.log(adEl.innerHTML);
// Execute low-risk logic
case 204:
// If a timeout occurs, show the ad, assuming low-risk logic
adEl.innerHTML = '203 Non-Authoritative Information';
console.log(adEl.innerHTML);
break;
case 500:
adEl.innerHTML = '500 Internal Server Error';
console.log(adEl.innerHTML);
// Execute high-risk logic
break;
case 401:
parent.my_var='true';
//alert(parent.my_var);
alert(testad(parent.my_var));
return true;
console.log(adEl.innerHTML);
// Execute high-risk logic
break;
default:
// Invalid authentication
console.log(statusCode);
adEl.innerHTML = 'Invalid authentication';
console.log(adEl.innerHTML);
break;
}
}
</script>
is there any way i can do that in html also it is showing warning "Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened". Sorry i am beginner to all these things