August 18, 200917 yr Hi, Trying to embed a google map into a web site and keep getting a validation error from the W3C checker Line 64, Column 50: document type does not allow element "body" here <body onload="initialize()" onunload="GUnload()"/> The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed). One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error). I think I have follwed the Google instructions and the problem is certainly with the position of the 'onload' statement at line 64. HTML code below 1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3. <html xmlns="http://www.w3.org/1999/xhtml"> 4. <head> 5. <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" /> 6. <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 7. <title>Google Maps JavaScript API Example</title> 8. <link rel="stylesheet" href="styles.css" type="text/css" /> 9. <script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&sensor=true_or_false" type="text/javascript"> 10. </script> 11. <script type="text/javascript"> 12. //<![CDATA[ 13. 14. function initialize() { 15. if (GBrowserIsCompatible()) { 16. var map = new GMap2(document.getElementById("map_canvas")); 17. map.setCenter(new GLatLng(50.802408, -3.077239), 13); 18. map.setUIToDefault(); 19. map.openInfoWindow(map.getCenter(), 20. document.createTextNode("Summer Lodge is here")); 21. } 22. } 23. 24. //]]> 25. </script> 26. <style type="text/css"> 27. /*<![CDATA[*/ 28. <!-- 29. .style2 { 30. font-size: 36px; 31. color: #DDD8D8; 32. } 33. .style3 {color: #DDD8D8} 34. .style6 {font-size: xx-small} 35. --> 36. /*]]>*/ 37. </style> 38. 39. <style type="text/css"> 40. /*<![CDATA[*/ 41. div.c1 {width: 600px; height: 400px} 42. /*]]>*/ 43. </style> 44. </head> 45. <body> 46. <div id="container"> 47. <div id="header"> 48. <h1 class="style3">Summer Lodge</h1> 49. <h3 class="style2">Luxury Bed & Breakfast in East Devon</h3> 50. </div> 51. <div id="nav"> 52. <ul> 53. <li><a href="SLHome.html">Welcome</a></li> 54. <li><a href="About%20Us.html">About Us</a></li> 55. <li><a href="Rooms%20and%20Tarrif.html">Rooms & Tariff</a></li> 56. <li><a href="Facilities.html">Activities & Locality</a></li> 57. <li><a href="Comments.html">Guest Comments</a></li> 58. <li><a href="How%20to%20Find%20Us.html">How To Find Us</a></li> 59. <li><a href="Contact%20Us.html">Contact Us</a></li> 60. </ul> 61. </div> 62. <div id="content"> 63. <div id="googlemap"> 64. <body onload="initialize()" onunload="GUnload()"/> 65. <div id="map_canvas" class="c1"></div> 66. </div> 67. <div class="clear"></div> 68. </div> 69. <div class="style6" id="footer">Summer Lodge<br /> 70. Dalwood, Axminster, East Devon, EX13 7HW.</div> 71. </div> 72. </body> 73. </html> 74. 75. Probably my lack of experience - any helpto resolve gratefully accpeted (web page works OK ?) John C
August 18, 200917 yr You can only have one BODY. Replace <body onload="initialize()" onunload="GUnload()"/> with your first <body>
Create an account or sign in to comment