ZeroShade Posted October 25, 2006 Share Posted October 25, 2006 Before I added javascript to the page, the xhtml validated and everything was good. Now that I have javascript in the page, it doesn't want to validate. Can somebody help me validate and fix this page? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head profile="http://gmpg.org/xfn/11"> <!-- Martin vanPutten, Assignment 2 - Branding And The Web --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Coca-Cola</title> <link rel="stylesheet" href="styles.css" type="text/css" /> <link rel="stylesheet" href="iestyles.css" type="text/css" /> </head> <body> <script LANGUAGE="JavaScript"><!-- Original: Kurt Grigg (kurt.grigg@virgin.net) --><!-- Web Site: http://website.lineone.net/~kurt.grigg/javascript --><!-- This script and many more are available free online at --><!-- The JavaScript Source!! http://javascript.internet.com --><!-- This script has been modified by I, Martin vanPutten to better suit the pages. -->Image0 = new Image();Image0.src = "BubBlack.gif";Amount = 10; Ymouse = -50;Xmouse = -50;Ypos = new Array();Xpos = new Array();Speed = new Array();rate = new Array();grow = new Array();Step = new Array();Cstep = new Array();nsSize = new Array();ns = (document.layers)?1:0;(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;function Mouse(evnt) {Ymouse=(document.layers)?evnt.pageY-20:event.y-20;Xmouse=(document.layers)?evnt.pageX:event.x;}(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;for (i = 0; i < Amount; i++) {Ypos[i] = Ymouse;Xpos[i] = Xmouse;Speed[i] = Math.random()*4+1;Cstep[i] = 0;Step[i] = Math.random()*0.1+0.05;grow[i] = 8;nsSize[i] = Math.random()*15+5;rate[i] = Math.random()*0.5+0.1;}if (ns) {for (i = 0; i < Amount; i++) {document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+"></LAYER>"); }}else {document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');for (i = 0; i < Amount; i++) {document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');}document.write('</div></div>');}function MouseBubbles() {var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;for (i = 0; i < Amount; i++){sy = Speed[i] * Math.sin(270 * Math.PI / 180);sx = Speed[i] * Math.cos(Cstep[i] * 4);Ypos[i] += sy;Xpos[i] += sx; if (Ypos[i] < -40) {Ypos[i] = Ymouse;Xpos[i] = Xmouse;Speed[i] = Math.random() * 6 + 4;grow[i] = 8;nsSize[i] = Math.random() * 15 + 5;}if (ns) {document.layers['sn'+i].left = Xpos[i] + wscrll;document.layers['sn'+i].top = Ypos[i] + hscrll;}else {si[i].style.pixelLeft = Xpos[i] + wscrll;si[i].style.pixelTop = Ypos[i] + hscrll;si[i].style.width = grow[i];si[i].style.height = grow[i]; }grow[i] += rate[i]; Cstep[i] += Step[i];if (grow[i] > 24) grow[i] = 25;}setTimeout('MouseBubbles()', 10);}MouseBubbles();</script> <div id="title"> <img src="logo.gif" alt="" /> </div> <h2 id="navtitle">Navigation</h2> <div id="nav"> <ul> <li><a href="index.html" title="Home page.">Home</a></li> <li><a href="info.html" title="Company information.">Company</a></li> <li><a href="flavors.html" title="Different Coke flavors.">Flavors</a></li> <li><a href="diet.html" title="Diet Coke.">Diet</a></li> <li><a href="products.html" title="Every Coca-Cola product.">Products</a></li> <li><a href="collect.html" title="Coca-Cola collectables.">Collectables</a></li> <li><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" id="validate" /></a></li> </ul> </div> <div id="main"> <h1><strong>Coca-Cola</strong></h1> <h2>Welcome!</h2> <h4>Coca-Cola is proud to present our newest product! The Coca-Cola Blak! Now coffee lovers can rejoice while drinking their favorite brand of cola, Coca-Cola!</h4> <p />This is the one website where you can find everything on or about Coca-Cola. We don't just offer that amazing flavor of cola, but other products as well such as Five Alive or Frutopia. But it doesn't stop there! Check out the collectables to see what there really is out there in the world of Coca-Cola! <p /><div id="info"> <address> Coca-Cola Enterprises Inc. · 2500 Windy Ridge Parkway · Suite 700 · Atlanta, GA 30339 · UNITED STATES <br />Tel. (770) 989-3000 · Fax. (770) 989-3788 </address> <br />© 2006 The Coca-Cola Company, All rights reserved. "Coca-Cola" is a registered trademark of The Coca-Cola Company. </div> </div> </body></html> Link to comment Share on other sites More sharing options...
jhecht Posted October 25, 2006 Share Posted October 25, 2006 change this line <script LANGUAGE="JavaScript"> To EXACTLY this line: <script type="text/javascript" language="javascript"> And that should do the trick. Link to comment Share on other sites More sharing options...
ZeroShade Posted October 25, 2006 Author Share Posted October 25, 2006 It didn't do the trick. There were 15 errors before, now there are 16. Is it possible to put javascript in an external document, kind of like a stylesheet, because that would fix the problem for sure! Link to comment Share on other sites More sharing options...
jesh Posted October 25, 2006 Share Posted October 25, 2006 <script type="text/javascript" src="myscript.js"></script> Link to comment Share on other sites More sharing options...
ZeroShade Posted October 25, 2006 Author Share Posted October 25, 2006 Sorry, that doesn't work at all... the script does nothing. Is it even possible to validate it? Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 25, 2006 Share Posted October 25, 2006 Did you replace "myscript.js" with the URL of your hosted script? You know you have to host it, right? Link to comment Share on other sites More sharing options...
scott100 Posted October 25, 2006 Share Posted October 25, 2006 Sorry, that doesn't work at all... the script does nothing. Is it even possible to validate it?Make these 2 changes and your document will validate as strict.The attribute "language" has been deprecated from strict validation, use "type" instead. All javascript must be enclosed within <![CDATA[]]> - This tells the parser to ingore all code within it. <script type="text/javascript"><![CDATA[//Put all javascript content here]]></script>That's it :)oh yeah, you need to use © for a copyright symbol and get rid of the dots after the address lines. Link to comment Share on other sites More sharing options...
ZeroShade Posted October 26, 2006 Author Share Posted October 26, 2006 Ok... your right, it does validate... but the javascript doesn't work. It gives me a script error in the browser. Did I place the code in wrong? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head profile="http://gmpg.org/xfn/11"> <!-- Martin vanPutten, Assignment 2 - Branding And The Web --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Coca-Cola</title> <link rel="stylesheet" href="styles.css" type="text/css" /> <link rel="stylesheet" href="iestyles.css" type="text/css" /> <script type="text/javascript"><![CDATA[<!-- Original: Kurt Grigg (kurt.grigg@virgin.net) --><!-- Web Site: http://website.lineone.net/~kurt.grigg/javascript --><!-- This script and many more are available free online at --><!-- The JavaScript Source!! http://javascript.internet.com --><!-- This script has been modified by I, Martin vanPutten to better suit the pages. -->Image0 = new Image();Image0.src = "bub.gif";Amount = 10; Ymouse = -50;Xmouse = -50;Ypos = new Array();Xpos = new Array();Speed = new Array();rate = new Array();grow = new Array();Step = new Array();Cstep = new Array();nsSize = new Array();ns = (document.layers)?1:0;(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;function Mouse(evnt) {Ymouse=(document.layers)?evnt.pageY-20:event.y-20;Xmouse=(document.layers)?evnt.pageX:event.x;}(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;for (i = 0; i < Amount; i++) {Ypos[i] = Ymouse;Xpos[i] = Xmouse;Speed[i] = Math.random()*4+1;Cstep[i] = 0;Step[i] = Math.random()*0.1+0.05;grow[i] = 8;nsSize[i] = Math.random()*15+5;rate[i] = Math.random()*0.5+0.1;}if (ns) {for (i = 0; i < Amount; i++) {document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+"></LAYER>"); }}else {document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');for (i = 0; i < Amount; i++) {document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');}document.write('</div></div>');}function MouseBubbles() {var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;for (i = 0; i < Amount; i++){sy = Speed[i] * Math.sin(270 * Math.PI / 180);sx = Speed[i] * Math.cos(Cstep[i] * 4);Ypos[i] += sy;Xpos[i] += sx; if (Ypos[i] < -40) {Ypos[i] = Ymouse;Xpos[i] = Xmouse;Speed[i] = Math.random() * 6 + 4;grow[i] = 8;nsSize[i] = Math.random() * 15 + 5;}if (ns) {document.layers['sn'+i].left = Xpos[i] + wscrll;document.layers['sn'+i].top = Ypos[i] + hscrll;}else {si[i].style.pixelLeft = Xpos[i] + wscrll;si[i].style.pixelTop = Ypos[i] + hscrll;si[i].style.width = grow[i];si[i].style.height = grow[i]; }grow[i] += rate[i]; Cstep[i] += Step[i];if (grow[i] > 24) grow[i] = 25;}setTimeout('MouseBubbles()', 10);}MouseBubbles();]]></script> </head> <body> <div id="title"> <img src="logo.gif" alt="" /> </div> <h2 id="navtitle">Navigation</h2> <div id="nav"> <ul> <li><a href="index.html" title="Home page.">Home</a></li> <li><a href="info.html" title="Company information.">Company</a></li> <li><a href="flavors.html" title="Different Coke flavors.">Flavors</a></li> <li><a href="diet.html" title="Diet Coke.">Diet</a></li> <li><a href="products.html" title="Every Coca-Cola product.">Products</a></li> <li><a href="collect.html" title="Coca-Cola collectables.">Collectables</a></li> <li><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" id="validate" /></a></li> </ul> </div> <div id="main"> <h1><strong>Coca-Cola</strong></h1> <h2>Welcome!</h2> <h4>Coca-Cola is proud to present our newest product! The Coca-Cola Blak! Now coffee lovers can rejoice while drinking their favorite brand of cola, Coca-Cola!</h4> <p />This is the one website where you can find everything on or about Coca-Cola. We don't just offer that amazing flavor of cola, but other products as well such as Five Alive or Frutopia. But it doesn't stop there! Check out the collectables to see what there really is out there in the world of Coca-Cola! <p /><div id="info"> <address> Coca-Cola Enterprises Inc. · 2500 Windy Ridge Parkway · Suite 700 · Atlanta, GA 30339 · UNITED STATES <br />Tel. (770) 989-3000 · Fax. (770) 989-3788 </address> <br />© 2006 The Coca-Cola Company, All rights reserved. "Coca-Cola" is a registered trademark of The Coca-Cola Company. </div> </div> </body></html> Link to comment Share on other sites More sharing options...
jhecht Posted October 26, 2006 Share Posted October 26, 2006 I use transitional and my code always validates.... Link to comment Share on other sites More sharing options...
scott100 Posted October 26, 2006 Share Posted October 26, 2006 Ok... your right, it does validate... but the javascript doesn't work. It gives me a script error in the browser. Did I place the code in wrong?Maybe, in your first post you had the javascript in the <body> tag, now you have it in the <head> tagMake that change and see if it works Link to comment Share on other sites More sharing options...
ZeroShade Posted October 26, 2006 Author Share Posted October 26, 2006 I tried that just before I replied to your message... it doesn't work there either... I just prefer my javascript in the head section. Link to comment Share on other sites More sharing options...
jhecht Posted October 26, 2006 Share Posted October 26, 2006 What error is it that you are getting? Link to comment Share on other sites More sharing options...
ZeroShade Posted October 27, 2006 Author Share Posted October 27, 2006 Syntax error at line 10, which is the CDATA code. Link to comment Share on other sites More sharing options...
scott100 Posted October 27, 2006 Share Posted October 27, 2006 Syntax error at line 10, which is the CDATA code. Comment out the <![CDATA[]]> - javascript will ignore it but the parser wont.<script type="text/javascript">//<![CDATA[//]]></script>Sorted? Link to comment Share on other sites More sharing options...
ZeroShade Posted October 27, 2006 Author Share Posted October 27, 2006 Comment out the <![CDATA[]]> - javascript will ignore it but the parser wont.<script type="text/javascript">//<![CDATA[//]]></script>Sorted?Sorted!! Thanks a million. I sometimes wonder how people like you know this stuff... like to do that "//"... well... I guess I know now . Link to comment Share on other sites More sharing options...
scott100 Posted October 27, 2006 Share Posted October 27, 2006 Sorted!! Thanks a million. I sometimes wonder how people like you know this stuff... like to do that "//"... well... I guess I know now .Cool You pick these things up as time goes by, one day use will be passing on your knowledge. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now