Iframes Not Valid In Xhtml Strict February 04, 2024 Post a Comment I am building a website with a Google Map, which by default generates this code: Solution 1: 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 htmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">CopyHowever 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.Solution 2: There exists a dirty trick with Javascript:functionload() { document.getElementById("ramec").innerHTML = '<iframe class="ramec"></iframe>'; } Copyand:<!DOCTYPE htmlPUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="cs"lang="cs"><head><metahttp-equiv="content-type"content="text/html; charset=utf-8" /><scripttype="text/javascript"src="yourjshere.js"></script><title></title></head><bodyonload="load()"><divid="ramec"></div></body></html>CopyThe document in the first link validates as XHTML1.0 Strict, although it uses iframe inside (try the links inside the document). The important part is that Javascript which puts iframe into the document is external.I'm not sure if it worth all the effort. Maybe changing to HTML4.1 Strict document type would be much more helpful there (the rendering of page would be the same as with XHTML1.0 Strict).Solution 3: An object tag performs the same function, no hacks required. Just change the "src" attribute to "data" and add type="text/html".<objectwidth="550"height="500"data="http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=Amber,+115+Portswood+Road,+Southampton,+SO17+2FX,+United+Kingdom&aq=0&sll=50.923556,-1.394663&sspn=0.006709,0.01929&vpsrc=6&ie=UTF8&hq=Amber,&hnear=115+Portswood+Rd,+Southampton+SO17+2,+United+Kingdom&t=m&ll=50.923178,-1.393676&spn=0.012985,0.027466&z=15&output=embed"type="text/html"></object>Copy Share Post a Comment for "Iframes Not Valid In Xhtml Strict"
Post a Comment for "Iframes Not Valid In Xhtml Strict"