[OpenLayers-Users] DOCTYPE causes scripts to fail

Paul Spencer pspencer at dmsolutions.ca
Sun Feb 11 13:23:03 EST 2007


I highly recommend that everyone read this article:

http://www.quirksmode.org/css/quirksmode.html

There is a link at the right to this page which shows what happens in  
each browser depending on the doctype you choose:

http://hsivonen.iki.fi/doctype/

I have had a lot of success standardizing on the following doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ 
TR/html4/strict.dtd">

This makes all the major browsers work in standards (or almost  
standards) mode.  Any choice you make yields predictable behaviour  
but with standards mode, you seem to get less differences between the  
browsers, or at least less weird stuff going on.

Cheers

Paul

On 9-Feb-07, at 3:30 PM, Gary Townsend wrote:

> Yes you're right my apologies I hit send before thinking my request  
> full
> through.
>
> The errors I get vary on the browser in fire fox I get:
>
> Error: this.position has no properties
> Source File: http://localhost/lib/OpenLayers/Tile.js
> Line: 103
>
> IE 6 I get
> Line: 66
> Error: this.tile is null or not an object
>
> If I hit no to debug I then get
>
> Line: 413
> Error: Number Expected
>
> I hadn't tried it in any other browsers.
>
> These are the Doctype declarations I have tried it with.
>
> DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
> !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
> "http://www.w3.org/TR/html4/frameset.dtd"
>
> !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
>
> The Javascript:
> <script src="/lib/OpenLayers.js"></script>
> <scripttype="text/JavaScript">
> function init(){
> 		var map = new OpenLayers.Map('map',
> {'maxResolution':'auto'});
> 		var ol_wms = new OpenLayers.Layer.WMS.Untiled(
> "Globe","http://www.resmap.com/resmapserver/mapserv.exe?map=C:/ 
> Inetpub/Resma
> pRoot/ResmapSearch.map", {layers: 'Globe', format: 'jpeg'},{ratio: 
> 1} );
> 		var pb_wms = new
> OpenLayers.Layer.WMS.Untiled("Borders","http://www.resmap.com/ 
> resmapserver/m
> apserv.exe?map=C:/Inetpub/resmaproot/ResmapSearch.map", {layers:
> 'PoliticalBoundaries',format: 'gif', transparent:'true'} );
>
> 		map.addLayers([ol_wms,pb_wms]);
> 		map.addControl(new OpenLayers.Control.LayerSwitcher());
> 		map.setCenter(new OpenLayers.LonLat(0, 0),0);
> 		map.events.register("zoomend",map,function(e){
> 		var mapBounds = new OpenLayers.Bounds();
> 		mapBounds = map.getExtent();
> 		document.forms[0].txtMinX.value = mapBounds.left;
> 		document.forms[0].txtMinY.value = mapBounds.bottom;
> 		document.forms[0].txtMaxX.value = mapBounds.right;
> 		document.forms[0].txtMaxY.value = mapBounds.top;
> 		});
> 		map.events.register("moveend",map,function(e){
> 		var mapBounds = new OpenLayers.Bounds();
> 		mapBounds = map.getExtent();
> 		document.forms[0].txtMinX.value = mapBounds.left;
> 		document.forms[0].txtMinY.value = mapBounds.bottom;
> 		document.forms[0].txtMaxX.value = mapBounds.right;
> 		document.forms[0].txtMaxY.value = mapBounds.top;
> });
> </script>
>
> -----Original Message-----
> From: Christopher Schmidt [mailto:crschmidt at metacarta.com]
> Sent: February 9, 2007 11:45 AM
> To: Gary Townsend
> Cc: users at openlayers.org
> Subject: Re: [OpenLayers-Users] DOCTYPE causes scripts to fail
>
> On Fri, Feb 09, 2007 at 10:17:56AM -0800, Gary Townsend wrote:
>> I have a page that with no doctype declared in the html the map  
>> displays
>> just fun but when the designers apply their templates OpenLayers  
>> starts
>> returning errors. I saw the XHTML patch through google but was  
>> unsure a)if
>> that would affect my problem since this is affecting even HTML  
>> Doctypes b)
>> how I would apply it if it did fix my problem.
>
> 1. Are you using the single file build, or the developement
>    automatic script-include builds?
>
> 2. Something more specific than 'starts returning errors' is neccesary
>    here. Starting from an example and showing the smallest number of
>    changes to cause an error is most beneficial, but if you can't do
>    that, an example HTML page, or even an error message that you get,
>    would be helpful in resolving problems.
>
> Regards,
> -- 
> Christopher Schmidt
> MetaCarta
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+







More information about the Users mailing list