Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning JavaScript 4th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 4th Edition by Paul Wilton, Jeremy McPeak; ISBN: 978-0-470-52593-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 4th Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2011, 02:56 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 3
Thanked 0 Times in 0 Posts
Default 1st Chapter Problem 2 again!!!

Here's a code that I originally wrote in Notepad:
Code:
<script>
alert ("THIS IS MAGIC");
document.bgColor = "BLACK";
</script>
<script>
alert ("UH OH!!!");
document.bgcolor = "ORANGE";
</script>
<html>
<head>
<script>
alert ("AND AGAIN");
document.bgColor = "RED";
</script>
<title> JAVA DOC 1 </title>
</head>
<body>
<h2> <p align = center> <br><br> This is my first piece of JavaScript code. </p> </h2>
</body>
</html>
And Firebug 1.9.0a0 made it into:
Code:
html>
<head>
<script>
alert ("THIS IS MAGIC");
document.bgColor = "BLACK";
</script>
<script>
alert ("UH OH!!!");
document.bgcolor = "ORANGE";
</script>
<script>
alert ("AND AGAIN");
document.bgColor = "RED";
</script>
<title> JAVA DOC 1 </title>
</head>
<body>
<h2>
<p align="center">
<br>
<br>
This is my first piece of JavaScript code.
</p>
</h2>
</body>
</html>
That's how browsers change the code, right?
Now the problem is that after the browser tidies up the code, the background colour is set first to black, orange then red. So finally red, right?
But the output is simple:
"This is my first piece of JavaScript code." in black on a white background.
Can somebody explain this please?
 
Old August 1st, 2011, 10:52 AM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Howdy again, Ashu2912.

The easiest answer/solution is to just follow the HTML spec. HTML, CSS, and JavaScript behave more rationally/expectedly when the HTML spec is followed.
The Following User Says Thank You to jmcpeak For This Useful Post:
Ashu2912 (August 1st, 2011)
 
Old August 1st, 2011, 02:05 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Howdy jmcpeak

Quote:
Originally Posted by jmcpeak View Post
The easiest answer/solution is to just follow the HTML spec. HTML, CSS, and JavaScript behave more rationally/expectedly when the HTML spec is followed.
Can you explain what is HTML spec ?

Thank You....




Similar Threads
Thread Thread Starter Forum Replies Last Post
1st Chapter Example 2 Ashu2912 BOOK: Beginning JavaScript 4th Edition 1 July 27th, 2011 04:32 PM
Chapter 16: 1st 'Try It Out' Web.config error jee26 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 September 21st, 2008 09:35 AM
Chapter 2 - 1st exercise gomesdir BOOK: Beginning JavaServer Pages 4 April 6th, 2006 08:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.