HTML5 Tutorial – 25 – Working with JavaScript in HTML5




Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Original source


29 responses to “HTML5 Tutorial – 25 – Working with JavaScript in HTML5”

  1. So you saved the .js file in the same folder as the .html file? If we load the html content from a webserver like tomcat or glassfish, where would this js file go. I'm developing an web app in netbeans mainly using html5 and servlets so it'll be very helpful if you reply.

  2. <meta charset="UTF-8">
    <meta name="description" content="Free Web tutorials">
    <meta name="keywords" content="HTML,CSS,XML,JavaScript">
    <meta name="author" content="Hege Refsnes">              THE BEST MEATA TAGS

  3. The same id for two elements is bad form. Remember, "Use class to name multiple elements for the same description".

    Bucky knows this; he said just a few vids ago yet still makes armature mistake.

    HTML has no way to ERROR: nor handle twin ids as that would just break the code and prevent the page from displaying. When parsing the page the second of the twin id will just be over-looked or treated just like a class. Calling an element by id is just a format in design to make sure one specific element is targeted.

    Anyhow, good stuff.

  4. So I got my html file saved as Home.html on the desktop
    Then I got my javascript file saved as java.js on the desktop aslo.

    In the html file i got this code.
    <!doctype html>
    <html lang ="en">
    <head> 
    <meta charset="utf-8"/>
    <script src="java.js"> 
    </script>

    </head>

    <body>
    <div id="big_wrapper">

    <p id="tune">first</p>
    <p id="bacon">second</p>
    <p id="tuna">third</p>
    </div>
     
    </body>

    </html>

    In my Javascript file I have this code 

    function getStuff() {
    document.querySelector('#tune').oncick=talk;
    }

    function talk(){
    alert('hello');
    }

    window.onLoad=getStuff;

    When I run the Html file in google chrome, and try to click "first" nothing happens. 
    What the heck is going on !!!! Why isn't this working. Please help me  this is just getting so frustrating!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! arrrrrrr!!!

  5. why didn't the code work correctly when i directly put the alert function and removed the talk intermediate? like..

    function getstuff()
    {
    document.querySelector('#tuna').onclick=alert("yoyoma!");
    }
    window.onLoad=getstuff;

  6. insted of calling for an Alert would this be simular to a method we would use to direct a visitor to another link on our webpage for instance if they were to click on "home" ?

Leave a Reply