0

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

  • http://stackoverflow.com/questions/1197575/can-scripts-be-inserted-with-innerhtml – Joe. He Dec 04 '15 at 05:49
  • Why are you trying to write a `script` inside of a `script`? – Nick Zuber Dec 04 '15 at 05:51
  • i want to show ad in my website if some condition are true and i have js code for that ad – Gaurav Mehra Dec 04 '15 at 05:59
  • i got this error if i try to put the code in script which i want to run "forensiq implementation:13 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." – Gaurav Mehra Dec 04 '15 at 06:02

0 Answers0