0

Iv'd wanted to find out is it possible to change your IE mode after you'd set the doctype

Atm i can only set this specific doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 

Which make IE turn into Quirks mode. See this article for more info about doctypes and quirksmode

I don't have the possibility to change this what can i do to change this to like the newest IE standard available ?

I can only change the html, css and javascript

I cant set meta tags or anything cause the service we sent it to have a build step that set everything this way

Summed up:

Change the mode of the browser with javascript after a page load?

Simon Dragsbæk
  • 2,367
  • 3
  • 30
  • 53
  • Have you tried createDocumentType ? – karthick Jun 26 '13 at 08:58
  • i dont have access to the build step and the firm that makes this cant change it eather – Simon Dragsbæk Jun 26 '13 at 09:04
  • I don't know of any way to trigger standards mode without changing the doctype. You could set up a reverse proxy and make it replace the doctype on all outgoing documents! -- On a more serious note - a system that doesn't let you set the doctype might be a system in need of replacement :) – xec Jun 26 '13 at 09:20

2 Answers2

0

No, after the page has loaded and the doctype string and the meta tags have been parsed, nothing on the page can change the browser mode. The mode selection in IE is very complicated, see Activating Browser Modes with Doctype, but they have no provision for changing the mode via scripting.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
-2

IE automatically sets the rendering mode to Quirks mode if the Website is not valid HTML. You should try to use a validator (http://validator.w3.org/) to see what is wrong.

TSS
  • 139
  • 1
  • 1
  • 6
  • If you read the hole question isn't why it changes its can i change it back – Simon Dragsbæk Jun 26 '13 at 08:54
  • 2
    Validity of HTML has little to do with the rendering mode chosen as far as I know. What's your source? (I'm downvoting until proven wrong) ;) – xec Jun 26 '13 at 08:59
  • @xec — You're right, validity has nothing to do with it. Doctype that is the primary factor (I think some meta elements and possibly http headers may factor into it too … although only for IE). – Quentin Jun 26 '13 at 09:00
  • @bouscher it works fine in my pure markup and its flawless down to ie7 so its some where in the build step – Simon Dragsbæk Jun 26 '13 at 09:02
  • As far as I know, it is either a missing doctype declaration or invalid html, i.e. not complying with the doctype declaration, that triggers quirksmode: http://stackoverflow.com/questions/1695787/what-is-quirks-mode – bouscher Jun 26 '13 at 09:06
  • @bouscher You mean invalid **doctype**, rather than invalid html, I assume? – xec Jun 26 '13 at 09:08
  • Actually I mean both: "Generally, quirks mode is turned on when there is no correct DOCTYPE declaration, and turned off when there is a DOCTYPE definition. However, invalid HTML - with respect to the chosen DOCTYPE - can also cause the browser to switch to quirks mode." (http://stackoverflow.com/questions/1695787/what-is-quirks-mode) – bouscher Jun 26 '13 at 09:08
  • Anyway, doctype is readonly and I don't know of any method to change it with javascript. And even if it could be changed, I don't think that it would force the browser out of quirksmode after the page has been rendered already. – bouscher Jun 26 '13 at 09:10
  • 4
    I think the referenced answer is wrong. I've never seen any evidence to suggest that invalid HTML can trigger quirks mode. – Quentin Jun 26 '13 at 09:12
  • @Quentin Everything you said was right, I take everything back and stand corrected. So it is probably the missing system identifier ("http : //www.w3.org/TR/html4/loose.dtd") that causes the browser to trigger quirksmode. – bouscher Jun 26 '13 at 09:36
  • 1
    It isn't the missing system identifier specifically. You can have an HTML 4.01 Strict Doctype without one and trigger standards mode. Having HTML 4.01 Transitional without a system identifier triggers quirks mode. There's little logic about it, it is based (AFAIK) on a popularity contest for "which doctype strings were most commonly used on websites that depended on quirks mode" that ran when IE6 came out. – Quentin Jun 26 '13 at 09:38