document.write( "anything" ) 不会在 Internet Explorer 中作为外部脚本执行



我的javascript文件仅作为内部样式执行,当作为外部样式链接时,它无法执行。我正在IE浏览器中预览网页。但是,无论是作为内联还是外部JavaScript文件,它都可以在Chrome中执行。

这是我的 HTML:*

<!doctype html>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<script src="script.js">
</script>
</head>
<body>
<div class="wwd">
<a class="link1" href="URL">What We do</a>
</div>
<div class="wwd_content">
<p id="ss">Sell Shoes</p>
<p id="sc">Sell Cars</p>
<p id="sp">Sell Pets</p>
<p id="si">Sell Interiors</p>
</div>
<div class="acp">
<a class="link2" href="URL">ACP standards</a>
</div>
<div class="qg">
<a class="link3" href="URL">Quality guarantee</a>
</div>
<div class="nav_bar">
<h3 id="home">Home</h3>
<h3 id="products">Products</h3>
<h3 id="services">Services</h3>
<h3 id="contact">Contact Us</h3>
</div>
<div class="logo">
<h1> DW </h1>
<p>Demwu International</p>
</div>
</body>
</html>

这是我的JavaScript:

document.write("new web page");

这是因为您的脚本甚至在 dom 初始化之前就已执行。关闭正文后保留脚本标记。在此之前,您可以在地址栏中键入" javascript:document.write("<h1>new web page</h1>") ",没有开始和结束引号,然后按回车键

最新更新