...

View Full Version : Resolved xHTML Validation w/ Google Maps API



toddedw
05-14-2009, 02:08 AM
Hello Ladies and Gentlemen,

I hope some of you are familiar with the Google Maps API because I'm stumped. Here is my issue:



var point = new GLatLng(<?echo $dataArray[1].",".$dataArray[2]?>);
var marker = createMarker(point,'<div><?echo date('m-d-Y H:i:s',"$dataArray[0]")."<br />".round((($dataArray[4] / 1609.344)*60)*60)."mph<br /><br />";?></div>')
map.addOverlay(marker);


I'm basically creating a bubble on the map when someone clicks one of my way points. I need to have line breaks inside the bubble and so far xHTML will not validate no matter what I do. I'm stumped. Any ideas would be greatly appreciated.

Error:

1. Error Line 160, Column 44: document type does not allow element "div" here

…ar marker = createMarker(point,'<div>05-13-2009 21:07:27<br />0mph<br /><br /



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).


Thanks in advance!

VIPStephan
05-14-2009, 03:06 AM
Have you wrapped CDATA tags around your script (if inside HTML file)? In XHTML it should always look like this:


<script type="text/javascript">
// <![CDATA[

your script here

// ]]>
</script>

toddedw
05-14-2009, 03:14 AM
<script type="text/javascript">
// <![CDATA[

your script here

// ]]>
</script>

Thank you very much. It has been a long time since I have tinkered with JavaScript and my OCD nature cannot allow me to have anything less than xHTML strict.

Thanks again!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum