Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iFrame在XHTML Strict中无效_Html_Google Maps_Iframe_Xhtml_Xhtml 1.0 Strict - Fatal编程技术网

iFrame在XHTML Strict中无效

iFrame在XHTML Strict中无效,html,google-maps,iframe,xhtml,xhtml-1.0-strict,Html,Google Maps,Iframe,Xhtml,Xhtml 1.0 Strict,我正在使用谷歌地图构建一个网站,默认情况下,谷歌地图会生成以下代码: <iframe width="550" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Amber,+115+Ports

我正在使用谷歌地图构建一个网站,默认情况下,谷歌地图会生成以下代码:

<iframe width="550" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Amber,+115+Portswood+Road,+Southampton,+SO17+2FX,+United+Kingdom&amp;aq=0&amp;sll=50.923556,-1.394663&amp;sspn=0.006709,0.01929&amp;vpsrc=6&amp;ie=UTF8&amp;hq=Amber,&amp;hnear=115+Portswood+Rd,+Southampton+SO17+2,+United+Kingdom&amp;t=m&amp;ll=50.923178,-1.393676&amp;spn=0.012985,0.027466&amp;z=15&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Amber,+115+Portswood+Road,+Southampton,+SO17+2FX,+United+Kingdom&amp;aq=0&amp;sll=50.923556,-1.394663&amp;sspn=0.006709,0.01929&amp;vpsrc=6&amp;ie=UTF8&amp;hq=Amber,&amp;hnear=115+Portswood+Rd,+Southampton+SO17+2,+United+Kingdom&amp;t=m&amp;ll=50.923178,-1.393676&amp;spn=0.012985,0.027466&amp;z=15" style="color:#0000FF;text-align:left">View Larger Map</a></small>

现在,当检查XHTML Strict时,这会抛出一个错误,因为它是过时的帧,但是我应该使用什么来代替呢


感谢您的帮助

如果您的页面上必须有Maps iframe,最简单的解决方案是将doctype改为XHTML 1.0 Transitional,这允许使用iframe:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


但是,如果您开始看到页面呈现中的任何差异(请参阅),并且您更关心的是站点在web浏览器中的外观,而不是验证标记,那么只需保持XHTML1.0严格的doctype即可。浏览器不会仅仅因为页面是无效的XHTML而出错;无论哪种方式,它们都能很好地处理您的iframe。

Javascript存在一个肮脏的把戏:

function load()
{
    document.getElementById("ramec").innerHTML = '<iframe class="ramec"></iframe>';
}
函数加载()
{
document.getElementById(“ramec”).innerHTML='';
}
以及:


第一个链接中的文档验证为XHTML1.0 Strict,尽管它在内部使用iframe(尝试文档内部的链接)。重要的一点是,将iframe放入文档的Javascript是外部的


我不确定这是否值得所有的努力。也许更改为HTML4.1 Strict document type在那里会更有帮助(页面的呈现方式与XHTML1.0 Strict相同)。

对象标记执行相同的功能,无需任何黑客攻击。只需将“src”属性更改为“data”,并添加type=“text/html”


<!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" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="yourjshere.js">
</script>
<title></title>
</head>
<body onload="load()">
<div id="ramec">
</div>
</body>
</html>
<object width="550" height="500" data="http://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Amber,+115+Portswood+Road,+Southampton,+SO17+2FX,+United+Kingdom&amp;aq=0&amp;sll=50.923556,-1.394663&amp;sspn=0.006709,0.01929&amp;vpsrc=6&amp;ie=UTF8&amp;hq=Amber,&amp;hnear=115+Portswood+Rd,+Southampton+SO17+2,+United+Kingdom&amp;t=m&amp;ll=50.923178,-1.393676&amp;spn=0.012985,0.027466&amp;z=15&amp;output=embed" type="text/html"></object>