Force standards-mode in browsers, after the page has loaded
Asked Answered
T

1

6

I'm having a problem where i have a page that does not have a doctype.

I can't access it on the server so i can't add a doctype declaration myself.

This causes browsers to render in quirks mode and almost all designs need separate stylesheets for different explorer versions. Some difficult layouts don't even work on Firefox.

All of these problems would end if I could somehow tell the browsers (via JavaScript perhaps) to render in standards mode. Is there something I can do?

Thank you


Update from OP comment, below:

The page is generated out of my reach and it only puts my HTML (that can include javascripts) into a portion of its entire content.

It's nothing illegal or anything, it's just a custom ebay listing page that i need to render normally instead of collapsing every time and forcing me to apply all sorts of fixes.

Topfull answered 19/11, 2010 at 8:15 Comment(7)
How would you add a javascript inside a page if you say you can't access the server?Featherveined
@fcalderan, he could use an extension like Greasemonkey to do that.Jsandye
He could also do it via XSS, if the page involves some user input without escaping it when the response is output to browser.Johns
@Brock o_O he should install greasemonkey on every client showing that page? And for browser like IE? @Topfull please provide more informationFeatherveined
...but somehow XSS'ing a page to get it to render correctly in people's browser doesn't seem like a typical "use case" for XSS ;>)Johns
@Brock Ok, I am not a sensitive yet (but I'm working on), maybe it's like you say =)Featherveined
@fcalderan: no, i don't have access to server, but i can insert almost any html into that page. The page itself, however, is generated out of my reach and it only puts my html (that can include javascripts) into a portion of its entire content. It's nothing illegal or anything, it's just a custom ebay listing page that i need to render normally instead of collapsing everytime and forcing me to apply all sorts of fixes.Topfull
M
1

Here is the solution: http://www.webmasterworld.com/forum91/4856.htm

Remember, that

As for changing that with DOM methods, the W3C DOM Level 2 Core says: "docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode."

http://bytes.com/topic/javascript/answers/167854-dynamically-changing-doctype

Metallic answered 19/11, 2010 at 9:20 Comment(2)
By "solution" do you mean the document.write way or the dom manipulation way? I've tried the document.write and it simply puts the text at the curent position and i need to completely overwrite the source.Topfull
DOM manipulation :) I never checked that and you should not expect it will correctly work everywhere because of W3C comments. But it seems the only way.Metallic

© 2022 - 2024 — McMap. All rights reserved.