本文介绍了iframe在XHTML Strict中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个Google Map的网站,该网站默认会生成以下代码:

I am building a website with a Google Map, which by default generates this code:

<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时会抛出一个错误,因为它是过期的Frame,但是我应该用吗?

Now this throws an error when checked for XHTML Strict, as it is Frames which are outdated, but what should I use instead?

感谢您的帮助

Thanks for the help

推荐答案

如果您必须拥有Google地图iframe在你的页面上,最简单的解决方案就是将你的doctype改为XHTML 1.0 Transitional,它允许使用iframe:

If you must have a Maps iframe on your page, the easiest solution is to change your doctype to XHTML 1.0 Transitional instead, which permits the use of iframes:

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

但是,如果您开始在页面呈现中看到任何差异(请参阅),并且您更关心网站在网页浏览器中的效果,而不是验证标记,只保留XHTML 1.0严格的文档类型。浏览器不会因为页面无效而出错XHTML;他们会以任何方式处理您的iframe。

However if you start to see any differences in page rendering (see standards mode vs almost standards mode), and you're more concerned about how your site looks in web browsers than validating your markup, just keep the XHTML 1.0 Strict doctype. Browsers won't error out simply because a page is invalid XHTML; they'll handle your iframe just fine either way.

这篇关于iframe在XHTML Strict中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:05