Javascript for Beginners
-
I'm reading the book JavaScript for Beginners. As much as I hate it the fact is that web development is a part of my job. Anyways, anytime I learn something new I've a tendency to go way back to the beginning and start from scratch. I've written and maintained JavaScript before; however, there are just too many fundamentals that one misses when making a career out of cut-n-paste development. I never regret reading beginner books - I always learn something. One little tidbit I came across while mucking around with a beginner exercise is a short and frustrating little conundrum where I couldn't get an external .js file to include itself in my HTML page. As it turns out, the script tag had to have a separate closing script tag to function properly. One cannot use:
Anyone know the reason for that?
Anyways, I always find little tidbits like that and I consider well worth the time.
-
I'm reading the book JavaScript for Beginners. As much as I hate it the fact is that web development is a part of my job. Anyways, anytime I learn something new I've a tendency to go way back to the beginning and start from scratch. I've written and maintained JavaScript before; however, there are just too many fundamentals that one misses when making a career out of cut-n-paste development. I never regret reading beginner books - I always learn something. One little tidbit I came across while mucking around with a beginner exercise is a short and frustrating little conundrum where I couldn't get an external .js file to include itself in my HTML page. As it turns out, the script tag had to have a separate closing script tag to function properly. One cannot use:
Anyone know the reason for that?
Anyways, I always find little tidbits like that and I consider well worth the time.
No idea, but I too encountered that nuance.
-
I'm reading the book JavaScript for Beginners. As much as I hate it the fact is that web development is a part of my job. Anyways, anytime I learn something new I've a tendency to go way back to the beginning and start from scratch. I've written and maintained JavaScript before; however, there are just too many fundamentals that one misses when making a career out of cut-n-paste development. I never regret reading beginner books - I always learn something. One little tidbit I came across while mucking around with a beginner exercise is a short and frustrating little conundrum where I couldn't get an external .js file to include itself in my HTML page. As it turns out, the script tag had to have a separate closing script tag to function properly. One cannot use:
Anyone know the reason for that?
Anyways, I always find little tidbits like that and I consider well worth the time.
That syntax might work in an XHTML document served as
application/xhtml+xml
, but I haven't tried it. In an HTML document, the<script>
tag isn't an empty element; you can put the script inline between the opening and closing tags. Only empty/void elements can use the self-closing syntax.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I'm reading the book JavaScript for Beginners. As much as I hate it the fact is that web development is a part of my job. Anyways, anytime I learn something new I've a tendency to go way back to the beginning and start from scratch. I've written and maintained JavaScript before; however, there are just too many fundamentals that one misses when making a career out of cut-n-paste development. I never regret reading beginner books - I always learn something. One little tidbit I came across while mucking around with a beginner exercise is a short and frustrating little conundrum where I couldn't get an external .js file to include itself in my HTML page. As it turns out, the script tag had to have a separate closing script tag to function properly. One cannot use:
Anyone know the reason for that?
Anyways, I always find little tidbits like that and I consider well worth the time.
that is because the
script
tag is never intended to be an empty element and the rule is that any tag which is not defined as being able to be empty needs a closing tag. Read the following: http://www.w3.org/TR/xhtml1/#C_3[^] hope that helps. :)you want something inspirational??
-
that is because the
script
tag is never intended to be an empty element and the rule is that any tag which is not defined as being able to be empty needs a closing tag. Read the following: http://www.w3.org/TR/xhtml1/#C_3[^] hope that helps. :)you want something inspirational??
An interesting answer, and I suspect the 'correct' one.... however you can't use the same logic for
which exhibits the same quirks. In my mind, I'd have preferred the consistency from other tags, but I'm sure there is a better explanation out there somewhere!
Do you like fishes? I do.
-
An interesting answer, and I suspect the 'correct' one.... however you can't use the same logic for
which exhibits the same quirks. In my mind, I'd have preferred the consistency from other tags, but I'm sure there is a better explanation out there somewhere!
Do you like fishes? I do.
derek_bartram wrote:
you can't use the same logic for <div> which exhibits the same quirks
The
<div>
tag isn't an empty element either. You can only use the self-closing syntax with tags which will never have content -<br />
,<img />
, etc.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I'm reading the book JavaScript for Beginners. As much as I hate it the fact is that web development is a part of my job. Anyways, anytime I learn something new I've a tendency to go way back to the beginning and start from scratch. I've written and maintained JavaScript before; however, there are just too many fundamentals that one misses when making a career out of cut-n-paste development. I never regret reading beginner books - I always learn something. One little tidbit I came across while mucking around with a beginner exercise is a short and frustrating little conundrum where I couldn't get an external .js file to include itself in my HTML page. As it turns out, the script tag had to have a separate closing script tag to function properly. One cannot use:
Anyone know the reason for that?
Anyways, I always find little tidbits like that and I consider well worth the time.
The reason seems to be historical more than anything else. Since the
script
element was designed to have something inside it, the fact that we don't use it that way doesn't change the syntax required. If you are looking to reduce the size of your code (either for aesthetics or efficiency), it is valid HTML5 to leave out thelanguage
andtype
attributes:The same is true for
style
tags:is valid.
-
I'm reading the book JavaScript for Beginners. As much as I hate it the fact is that web development is a part of my job. Anyways, anytime I learn something new I've a tendency to go way back to the beginning and start from scratch. I've written and maintained JavaScript before; however, there are just too many fundamentals that one misses when making a career out of cut-n-paste development. I never regret reading beginner books - I always learn something. One little tidbit I came across while mucking around with a beginner exercise is a short and frustrating little conundrum where I couldn't get an external .js file to include itself in my HTML page. As it turns out, the script tag had to have a separate closing script tag to function properly. One cannot use:
Anyone know the reason for that?
Anyways, I always find little tidbits like that and I consider well worth the time.
Speaking of JavaScript; zero knowledge guy here; is the Java topic in this site the same one to use for JavaScript questions ? "much as I hate...." Totally understood; totally, completely, whatever. They want you to be an expert on embedded systems, I2C, SPI, and measure voltage to the 0.01 volt accuracy, on one pin, 35 feet away from the microprocessor, and then, you're also supposed to write the JavaScript for a 47 page website, and design the database and write the access code, etc., And get it done yesterday. Anyway, guess who's got to start studying that stuff, "much as I hate...."
-
Speaking of JavaScript; zero knowledge guy here; is the Java topic in this site the same one to use for JavaScript questions ? "much as I hate...." Totally understood; totally, completely, whatever. They want you to be an expert on embedded systems, I2C, SPI, and measure voltage to the 0.01 volt accuracy, on one pin, 35 feet away from the microprocessor, and then, you're also supposed to write the JavaScript for a 47 page website, and design the database and write the access code, etc., And get it done yesterday. Anyway, guess who's got to start studying that stuff, "much as I hate...."
-
JavaScript is pretty easy if you've experience in C#. Much of the syntax is the same. I'm enjoying the beginner book - it's a really quick read. I plan to pick up a more advanced text when I'm done. It's a nice way to close out a day of work.
Try copying stuff off the net: for some stupid reason, javascript coders love inline function definitions (like delegates) except that they define them during assignments instead of separately. Makes the code quite unreadable. The only other language I've used that can do something like that is Algol68.