I have just started learning JavaScript recently, and the tool I use is Adobe Dreamweaver CC 2017. After I finished writing the HTML file, I wanted to link to a JavaScript file, but the JavaScript file did not work. I don't know whether it's a problem with the software or something wrong with my code. After checking several times, there should be no path to link the JavaScript file, which can be seen in the picture.
My HTML code and JavaScript code are as follows:
Webville Tunes
window.onload=init; function init(){ "use strict"; var button=document.getElementById("addButton"); button.onclick=handleButtonClick; } function handleButtonClick(){ "use strict"; alert("Button was clicked!"); }
I hope all the seniors will give me some advice, I’m very grateful!
Thanks for the invitation. What I want to know is whether your js file is useful or not. To check whether the js is loaded correctly, open firebug and check whether the js you are looking for is loaded correctly. If it is not loaded correctly, 404 will be reported. If It is indeed loaded, then debug this js to see if there is any problem. The js code you wrote should work if you put it directly into the page. If it doesn't work, there may be something wrong with the loading path.
First of all, give up Dreamweaver. Secondly, choose webstrom, sublimeText or whatever.
Please don’t write it like this. Just remove window.onload, put the script reference at the end of the body and call init directly. .
There is no problem if the js part is added to the webpage, then you have to check to confirm
It can be run through, and the writing is no problem
You put the introduced connection after the ul tag.
What compiler are you using?