2016-02-02 124 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>