javascripthtmlmacostextedit

Textedit HTML source code not triggering javascript


Just getting back into coding after a very long break (approx 10 years) so apologies for any incorrect terminology / if this is a basic question.

-Max OS X -Text Edit -Google Chrome

Working on a course on Lynda on programming fundamentals. When I type the HTML source code like for like, my version doesn't trigger the .js file, whereas if I c+p the source code from the tutorial file, it does.

Using Textedit as my editor. Very confusing as it is very simple code, and I have copied it identically, but it doesn't react the same way when I type it myself. The rest of the HMTL loads fine but the .js script just doesn't load.

<html>
    <head>
        <title>Simple Page</title>
    </head>
    <body>
        <p>This is a very simple HTML page</p>
        <script src="script.js"></script>
    </body>
</html>

I've uploaded the files to mediafire. Container.html is from the tutorial. Container1.html is the HTML file I have typed out myself. Have been scratching my head over this for a while and can't figure out what the difference is between the 2 files except the size (4 bytes).

http://www.mediafire.com/file/p4sz93u9g6admwn/Textedit_JS_Problem.zip

Thanks!

H


Solution

  • It's because of double quotes in your Container2.html. So its seems the code changes its format from UTF to a different one. So what you need to is, open your container2.html file, and go to this line

    <script src=“script.js”></script>

    Change it to below by deleting double quotes and typing again:

    <script src="script.js"></script>

    Notice the change in double quote ;)