1. 程式人生 > >js控制臺報錯

js控制臺報錯

文件 style var 報錯 logs exp doc load 輸入

控制臺出現以下報錯時:

Uncaught SyntaxError: Unexpected token

註意檢查輸入符號是否錯誤;

出現以下報錯時:

Uncaught TypeError: Cannot read property ‘getElementsByTagName‘ of null

1. 檢查出錯行的id: banner和TagName: img 在相關的html頁面中是否存在;

var pics = document.getElementById("banner").getElementsByTagName("img")

2. 檢查html頁中引入js文件是否在body底部引入,若是在head標簽內引入並且在js中沒有用window.onload就可能出現以上報錯。

js控制臺報錯