我有这个脚本:
<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>
我希望在以下脚本调用
中的某些情况时运行此脚本<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>
有什么方法我可以在HTML中做到这一点,它也显示警告&#34;无法执行&#39;写&#39; on&#39; Document&#39;:除非明确打开&#34;,否则无法从异步加载的外部脚本写入文档。对不起,我是所有这些事情的初学者