如何用Javascript编写基本行

如何用Javascript编写基本行,javascript,Javascript,我是编程新手,正在阅读一本“开始编程”的书。它列出了在网站上编写基本行的以下代码: <!DOCTYPE html> <html> <body> <h1>This is a Test</h1> <script> document.write("<p>I like to code</p>"); document.write("<p>I will succeed at coding<

我是编程新手,正在阅读一本“开始编程”的书。它列出了在网站上编写基本行的以下代码:

<!DOCTYPE html>
<html>
<body>

<h1>This is a Test</h1>

<script>

document.write("<p>I like to code</p>");
document.write("<p>I will succeed at coding</p>");
</script>

</body>
</html>

这是一个测试
文档。写(“我喜欢编码”

”; 写(“我会成功编码”

”;
不幸的是,这条线

document.write("<p>I like to code</p>");
document.write(“我喜欢编码”

”;
没有给出网站上写的“我喜欢编码”的预期输出

如何编写此文件以获得此输出?


这是一个测试
文档。写(“我喜欢编码”

”; 写(“我会成功编码”

”;
您的代码似乎运行正常。尝试将您的HTML文件更新到以下位置:

<!DOCTYPE html>
<html>
    <body>
        <h1>This is a Test</h1>
        <script>
            document.write("<p>I like to code</p>");
            document.write("<p>I will succeed at coding</p>");
        </script>
        <noscript>
            Javascript is disabled!
        </noscript>
    </body>
</html>

这是一个测试
文档。写(“我喜欢编码”

”; 写(“我会成功编码”

”; Javascript被禁用!
如果您看到“Javascript已禁用!”则需要允许浏览器使用Javascript


祝你好运:)

结果如何?它在Firefox、Chrome和Opera中对我很有效。将显示所有三行文本。您的浏览器中是否禁用了Javascript?您是否正在考虑打印“我喜欢编码”而不是“我喜欢编码”?Mars,是的,它在Google Chrome中工作,但在Explorer中不工作。JS可能在我的浏览器中被禁用。如何在资源管理器中启用JS?