簡體   English   中英

我的外部javascript未執行

[英]My external javascript is not executed

我嘗試覆蓋外部javascript中的window.onload事件,但是即使將一些基本的console.log行放在window.load函數之外,代碼也似乎永遠不會執行。

跳轉到這里的代碼是:
對於index.html

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Canvas Experimentation</title>
    <script src="canvasEntry3D.js" type="type/javascript"></script>
</head>
<body>
    <canvas id="canvas" height="720" width="1280"></canvas>
</body>
</html>

對於canvasEntry3D.js

console.log("slkdfnsdnflknegs");
window.onload = abcdefg;
function abcdefg() {
     console.log("in start");
     var canvas = document.getElementById("canvas");
}

要真正知道瀏覽器是否已加載正確的javascript文件,我已經檢查了開發者控制台。

而且我不是要搜索兩次覆蓋window.onlad事件,因此不需要使用addEventListeners(也沒有其他JavaScript代碼可以覆蓋window.onload事件)

我看到的代碼中唯一的錯誤是腳本標記中的type屬性錯誤。

只需從

<script src="canvasEntry3D.js" type="type/javascript"></script>

<script src="canvasEntry3D.js" type="text/javascript"></script>

暫無
暫無

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

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