Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 38
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Location
    California
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript with HTML

    How do you use Javascript in HTML? I'm currently working on a project on Notepad++ and i'm trying to test out my newly learned skills. (Also if any of you could be my mentor can you could send me a message? Thanks.)

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    327
    Thanks
    3
    Thanked 35 Times in 35 Posts
    Have a look here: http://www.w3schools.com/.
    Frank

    How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Frankie View Post
    Have a look here: http://www.w3schools.com/.
    Only if your target audience uses Netscape 4 and earlier though.

    The correct way to do it for more modern browsers is covered at http://javascriptexample.net
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Regular Coder
    Join Date
    Sep 2011
    Posts
    327
    Thanks
    3
    Thanked 35 Times in 35 Posts
    Only if your target audience uses Netscape 4 and earlier though.
    The correct way to do it for more modern browsers is covered at http://javascriptexample.net
    Promoting your own site is one thing, but what you are saying is baloney, simply not true. There is not one modern browser that has any problem whatsoever with the javascripts on W3Schools. In fact, the whole coding community does it the way W3Schools advocates. You are the aberrant fundamentalist in this matter, making javascript unnecessarily complicated. And I would recommend W3Schools didactically speaking, anyway.
    Last edited by Frankie; 05-26-2013 at 03:46 PM.

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,478
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Frankie, just because W3Schools sounds official it doesn’t mean that it is. It’s an average site with a lot of outdated and/or erroneous code samples and isn’t promoting any good coding practices. Might I direct your attention to http://www.w3fools.com/ ?

    Also, felgall never said that modern browsers have problems with the code on W3Schools, he just implied that the code displayed there is in part so old that it would still work in Netscape 4, and in fact, this is making JavaScript (and web development in general) unnecessarily complicated. You can’t imagine how easy web development would be if nobody would write crappy, outdated code.

  • #6
    Regular Coder
    Join Date
    Sep 2011
    Posts
    327
    Thanks
    3
    Thanked 35 Times in 35 Posts
    Quote Originally Posted by VIPStephan View Post
    Frankie, just because W3Schools sounds official it doesn’t mean that it is. It’s an average site with a lot of outdated and/or erroneous code samples and isn’t promoting any good coding practices. Might I direct your attention to http://www.w3fools.com/ ?
    We already covered that topic, several times!! W3Fools is just a bunch of nerds that found a few -- non-fatal and trivial! -- errors and omissions, after scrutinizing the site from front to back. Big deal, looking at the fact that W3Schools covers many hundreds of topics!!! Furthermore, I never promoted W3Schools as an official source. Just as a good source when it comes to contents and an excellent source when it comes to didactics. Could you please, just for once, include those didactic qualities of W3Schools in your judgment? Or do you, like Felgall, expect beginners to understand high-tech "explanations" without head or tail?

    Quote Originally Posted by VIPStephan View Post
    Also, felgall never said that modern browsers have problems with the code on W3Schools,
    He did:
    Only if your target audience uses Netscape 4 and earlier though.
    Quote Originally Posted by VIPStephan View Post
    he just implied that the code displayed there is in part so old that it would still work in Netscape 4,
    Since when is backwards compatibility something that should be avoided??

    Quote Originally Posted by VIPStephan View Post
    and in fact, this is making JavaScript (and web development in general) unnecessarily complicated.
    That's baloney, too! Felgall's scripts are generally much more complicated and less intuitive than the "traditional" javascripts everyone else uses. Without any benefits over those scripts!

    Now could we please stop the jealous slander against W3Schools?? And no, I am in no way connected to them.
    Last edited by Frankie; 05-26-2013 at 05:17 PM.
    Frank

    How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Frankie View Post
    Now could we please stop the jealous slander against W3Schools?? And no, I am in no way connected to them.
    I wouldn't have expected you to be either of the TWO guys associated with the w3schools site. They wouldn't have time to post on forums. They would be spending all their time trying to update their site so as to try to slow the rate at which it is becoming outdated. If they were to both spend 24 hours a day on updating it for the next year years then they might be able to bring it to the point where it is current to 2012 instead of 2005 as currently. Presumably though as it isn't their full time jobs it will be more likely to take them ten years to reach that point.

    The w3fools site just points out a few examples where w3schools is now out of date. There are thousands of examples just for JavaScript where that site is out of date where the w3schools site doesn't even mention it.

    The biggest problem with w3schools is that any one topic there is big enough to keep the two owners occupied with keeping it up to date and they have enough topics there that they really ought to have 50 staff working on the site full time to keep it maintained - but there are just the two of them so it hasn't been kept up to date.

    The JavaScript section is the worst that I am aware of because many of the pages cover things that the new version of JavaScript released in 2011 no longer support and that browsers now only support if you tell them to treat the JavaScript as the old version - which results in lots of beginners asking questions about problems that couldn't happen if they were using the new version of JavaScript - eg. placing a second script on the same page and having one or both stop working. While the new version of JavaScript looks slightly more complicated than the old obsolete version, it is a million times easier to maintain because each script is completely separate instead of ALL the code being jumbled with the HTML.

    The current version of JavaScript uses the "use strict"; statement to tell the browser that the code uses current JavaScript and not JavaScript intended for Netscape 4 and earlier. If you add that statement to your web page and the JavaScript stops working then you are using outdated JavaScript. Many of the w3schools pages would stop working if you added that statement and so are clearly demonstrating obsolete JavaScript code intended for Netscape 4. The "use strict"; statement was specifically introduced so that antiquated JavaScript could continue to work in browsers since there is not enough time for everyone to rewrite all the antiquated code. All new JavaScript should be able to work if that statement is added.
    Last edited by felgall; 05-26-2013 at 08:40 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,478
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Quote Originally Posted by Frankie View Post
    Furthermore, I never promoted W3Schools as an official source. Just as a good source when it comes to contents and an excellent source when it comes to didactics.
    Well, OK then. Go and promote that site but get along with other people continuing to throw some light on the background of that site, misleading newbies, pretending to be an official educational institution (that even issues questionable certifications) when they arenít.

    Quote Originally Posted by Frankie View Post
    Felgall's scripts are generally much more complicated and less intuitive than the "traditional" javascripts everyone else uses.
    Oh yeah, then why not use document.write to write our HTML? Itís simple and working in all browsers.

  • #9
    New to the CF scene
    Join Date
    May 2013
    Location
    California
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Can I just get some help?

  • #10
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by NateK View Post
    Can I just get some help?
    There are about 400 examples of how to use JavaScript on my http://javascriptexample.net site. The first few in the Basics section show you how to correctly attach JavaScript to HTML.

    If you have any problems with being able to attach your JavaScript and get it working after working through the appropriate examples then I'd be happy to answer any specific questions that you have.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #11
    Regular Coder
    Join Date
    Sep 2011
    Posts
    327
    Thanks
    3
    Thanked 35 Times in 35 Posts
    Quote Originally Posted by felgall View Post
    The w3fools site just points out a few examples where w3schools is now out of date. There are thousands of examples just for JavaScript where that site is out of date where the w3schools site doesn't even mention it.
    We have been over this a number of times. Every time I asked you to come up with the evidence to support that statement. And every time you failed, apart from W3Fools, which only found a couple of non-fatal and trivial errors and omissions. So until you deliver that evidence, it is just cheap slander!

    Quote Originally Posted by felgall View Post
    All new JavaScript should be able to work if that statement ("use strict") is added.
    That is a ludicrous way of working. You tell a browser to not render "old" javascript anymore and then you blame the "old" javascript? That is the same as writing HTML3 code but putting an HTML5 doctype above it! That's ridiculous! And have you ever heard of backwards compatibility?

    Quote Originally Posted by VIPStephan View Post
    Well, OK then. Go and promote that site but get along with other people continuing to throw some light on the background of that site, misleading newbies, pretending to be an official educational institution (that even issues questionable certifications) when they aren’t.
    Well, seemingly not OK then. Because that falls under the same argument: "I never promoted W3Schools as an official source." Also, in the recent past I already agreed with you that the certificates are questionable at best.

    Quote Originally Posted by VIPStephan View Post
    Oh yeah, then why not use document.write to write our HTML? It’s simple and working in all browsers.
    If you wanna make a fool out of yourself with foolish arguments, go ahead.

    Quote Originally Posted by NateK View Post
    Can I just get some help?
    We gave you the direct links to two resources that will teach you. To be a successful coder, you have to be an autodidactic to a great extend. Especially because you asked an extremely general question.
    Last edited by Frankie; 05-26-2013 at 11:48 PM.

  • #12
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Frankie View Post
    We have been over this a number of times. Every time I asked you to come up with the evidence to support that statement.
    http://javascriptexample.net - it doesn't specifically list where w3schools is outdated but if you compare corresponding tutorials you should easily be able to find at least 100 instances where w3schools is out of date. I'd much rather spend the time developing web pages that teach people how to write JavaScript properly than waste time pointing out the hundreds of pages on someone else's site that are out of date.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #13
    Regular Coder
    Join Date
    May 2012
    Location
    USA
    Posts
    102
    Thanks
    0
    Thanked 7 Times in 7 Posts
    You can use the <SCRIPT> and </SCRIPT> tags to include JavaScript code directly into an HTML file.

  • Users who have thanked annaharris for this post:

    NateK (05-27-2013)

  • #14
    Regular Coder
    Join Date
    Sep 2011
    Posts
    327
    Thanks
    3
    Thanked 35 Times in 35 Posts
    Quote Originally Posted by felgall View Post
    http://javascriptexample.net - it doesn't specifically list where w3schools is outdated but if you compare corresponding tutorials you should easily be able to find at least 100 instances where w3schools is out of date. I'd much rather spend the time developing web pages that teach people how to write JavaScript properly than waste time pointing out the hundreds of pages on someone else's site that are out of date.
    Yeah, right. That is about the same as putting forward the database of a DNA lab and saying that there are at least 100 suspects in there, and that I should go look for myself. If you cannot at least point out 5 examples of the 100, or if you are not willing to put that time in it, your criticism remains cheap slander.
    Last edited by Frankie; 05-28-2013 at 12:41 AM.
    Frank

    How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.

  • #15
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Frankie View Post
    Yeah, right. That is about the same as putting forward the database of a DNA lab and saying that there are at least 100 suspects in there, and that I should go look for myself. If you cannot at least point out 5 examples of the 100, or if you are not willing to put that time in it, your criticism remains cheap slander.
    Fifteen examples that are really obvious just with the intro section:

    1. http://w3schools.com/js/js_intro.asp compare to http://javascriptexample.net/badjs02.php and http://javascriptexample.net/basics01.php

    using antiquated JavaScript in the very first example


    2. http://w3schools.com/js/js_howto.asp compare to http://javascriptexample.net/badjs12.php

    using calls that are for debugging use only in the second example

    3. http://w3schools.com/js/js_functions.asp compare to
    http://javascriptexample.net/badjs12.php and http://javascriptexample.net/basics15.php

    again using debugging calls in the example - also the way the functions are defined is not the best way (but the way they use does work most of the time)

    4. http://w3schools.com/js/js_comparisons.asp compare to http://javascriptexample.net/badjs06.php

    not differentiating between the comparison operators that always work anf those that cause a lot of the problems beginners have

    5. http://w3schools.com/js/js_loop_for.asp - another example the same as 1 above

    6. http://w3schools.com/js/js_loop_while.asp - yet an other example the same as 1.

    7. http://w3schools.com/js/js_errors.asp - only covers part of the statement - see http://javascriptexample.net/error01.php and http://javascriptexample.net/error03.php for the parts covered and http://javascriptexample.net/error02.php for the part that got left out

    8. http://w3schools.com/js/js_form_validation.asp - another example the same as 2.

    Also - completely missing from that tutorial series but essential to undersanding the basics of JavaScript:

    9. How to use <script> in place of <noscript>
    10. Feature sensing - http://javascriptexample.net/basics24.php
    11. identifying that you are using 21st century JavaScript instead of 20th century Javascript - http://javascriptexample.net/basics25.php
    12. How to avoid creating global variables - http://javascriptexample.net/basics27.php
    13. Where to put all your scripts (ant the rare exceptions) http://javascriptexample.net/basics01.php and http://javascriptexample.net/basics28php
    14. Testing - http://javascriptexample.net/basics99.php
    15. Using the error console - The Error Console

    And that's just what stands out at first glance as being wrong in the introductory JavaScript tutorials at w3schools - If I went through that section in detail (rather than just spending two minutes for a quick look) I could probably list at least 25 to 50 more things wrong with that section and similar lists for each of the other sections.

    Just the errors I have listed here are enough to demonstrate that w3schools is a completely useless place for beginners to learn JavaScript because it teaches all sorts of things that should never or very rarely be used in JavaScript in the first few tutorials - except if your script is targetting Netscape 4 and earlier where that way of coding was needed.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •