Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript 4th Edition
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?
Reply With Quote
  #2 (permalink)  
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.
Reply With Quote
The Following User Says Thank You to jmcpeak For This Useful Post:
Ashu2912 (August 1st, 2011)
  #3 (permalink)  
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....
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.