首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >OpenLayers不使用文档类型声明

OpenLayers不使用文档类型声明
EN

Stack Overflow用户
提问于 2012-05-02 12:11:22
回答 1查看 931关注 0票数 0

我有从netbean生成的以下代码,以及从这个link生成的一些修改。代码在删除后运行良好,而不是与之一起运行。可能的问题是什么?<!DOCTYPE html>

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
**<!DOCTYPE html>**
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>OpenLayers Example</title>
        <script src="http://openlayers.org/api/OpenLayers.js"></script>
    </h:head>
    <body>
        <div style="width:100%; height:100%" id="map"></div>
        <script defer="defer" type="text/javascript">
            var map = new OpenLayers.Map('map');
            var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
            "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
            var dm_wms = new OpenLayers.Layer.WMS(
            "Canadian Data",
            "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
            {
                layers: "bathymetry,land_fn,park,drain_fn,drainage," +
                    "prov_bound,fedlimit,rail,road,popplace",
                transparent: "true",
                format: "image/png"
            },
            {isBaseLayer: false}
        );
            map.addLayers([wms, dm_wms]);
            map.zoomToMaxExtent();
        </script>

    </body>
</html>
EN

回答 1

Stack Overflow用户

发布于 2012-05-02 12:57:23

无论是您正在使用的应用程序接口,还是您使用它的方式,都依赖于浏览器中的Quirks Mode (即,一种浏览器故意偏离标准和规范的模式,以模拟老的有buggy的浏览器)。

顺便说一句,与模式无关,Firefox会报告以下错误:

代码语言:javascript
运行
复制
document.getElementsByTagName("head")[0] is undefined
Source: http://openlayers.org/api/OpenLayers.js
Line: 424

此外,页面在两种模式下都显示为空。这就是你所说的“行不通”吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10407595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档