簡體   English   中英

html 中的外部 javascript 文件不起作用

[英]External javascript file in html not working

第一個帖子.. 第一次嘗試 javascript。 我正在關注一本書,在同一目錄 test_js.html helloWorld.js 中創建了兩個文件

兩者的內容如下: test_js.html

<html>
<head>
<title> First Javascript page </title>
<script type="text/javascript" src="helloWorld.js"></script>
</head>
<body></body>
</html>

你好世界.js

<script type="text/javascript">
alert("hello");
</script>

當我加載 html 頁面時,我沒有看到任何警報。 但是,如果我在 html 頁面中嵌入相同的警報(“你好”),我會看到正在顯示警報。

在 chrome 和 firefox(都是最新的)上試過這個,結果相同。 以下 googled 示例未顯示任何文件中的任何錯誤。

請幫忙。

從 helloWorld.js 中刪除腳本標簽

只是

alert("hello");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM