If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

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.)

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.

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.

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?

Originally Posted by VIPStephan

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.

Originally Posted by VIPStephan

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??

Originally Posted by VIPStephan

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.

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.

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.

Originally Posted by Frankie

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.

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!

Originally Posted by felgall

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?

Originally Posted by VIPStephan

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.

Originally Posted by VIPStephan

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.

Originally Posted by NateK

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.

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.

Users who have thanked annaharris for this 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.

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.

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.