2016-02-02 128 views
-2

所有我设计的网站上的网页是有效的XHTML 1.0 Strict标准,除了这是从我的地图生成W3C验证错误

<div id="map"> 
<iframe src="https://www.google.com/maps/d/embed?mid=zBNEhg5_DRUg.ke97rR7SIh5I" width="320" height="240"></iframe>  
</div> 

的错误是一个谷歌地图链接的主页:

there is no attribute "src" 
there is no attribute "width" 
there is no attribute "height" 
element "iframe" undefined 

我已阅读的一些文章建议用替代品替代这些文章,但我不知道如何。

有没有原因不使用谷歌地图生成器?

回答

0

要验证谷歌嵌入式地图,您不需要使用,这在XHTML Strict中是不允许的。请使用<object>(参考:Why won't <iframe> elements validate in HTML 4.01?),而不是src(不支持),请使用data

example that valids XHTML Strict 1.0

<!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"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>example embedded map</title> 
</head> 
<body> 
    <div> 
    <object width="600" height="450" style="border:0" data="https://www.google.com/maps/embed/v1/directions?key=API_key&amp;origin=Bern&amp;destination=Bern&amp;waypoints=Paris%7CBerlin%7CRome"></object> 
    </div> 
</body> 
</html>