Frage

I am designing a site based a .NET software CMS solution that doesn't follow current best practices. It uses tables and a doctype of <!-- DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" -->. The software company doesn't let you edit .aspx files or js. They only let you edit the stylesheet and different modules, e.g. HTML module, weather module, slideshow module, etc.

Thus, IE always renders the site in quirks mode breaking the CSS. I do not have access to change the doctype or edit anything in <head></head>.

Is there a way to change the doctype without being able to access the code?

What I have to deal with:

<!--DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" -->
<html>
<head id="htmlHead"><title>
Welcome to xxx
</title>

<script type="text/javascript" language="JavaScript">
        function stopError()
        {
          return true;
        }
        window.onerror = stopError;
</script>

<link href="xxx.css" rel="stylesheet" type="text/css" />
<meta name="ROBOTS" content="INDEX,NOFOLLOW" />
<link href="xxx/favicon.ico" rel="SHORTCUT ICON" />
<style id="spMenuStyle"></style>
<link id="ApplicationRoot" rel="AppRoot" href="/xxx/" /><script type="text/javascript" src="/xxx/scripts/Utility.js">
</script>
<script type="text/javascript" language="javascript" sr="cxxx/BlockIFrame.js">
</script>
<link href="/xxx/WebResource.axd?d=9IeP9KvvsN3Ik1tvDsOJspkYjKE_KnZBT8bvXX7faYYRqxbjgHhLZKgtKfFSoL4-itgpmZrgTG68lyrA-SRm95xnEdLdUHa4j1nbnB_xoc_0zNWbtGMRDJOai6Kgu4UI0Dg5lw2&amp;t=634950712700000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" />
</head>
War es hilfreich?

Lösung

If you're able to inject your own JavaScript you might be able to inject the X-UA-Compatible meta tag.

This code will inject the meta tag and force IE to run in edge mode, which means IE will treat it as standards mode:

var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'x-ua-compatible');
meta.setAttribute('content', 'IE=edge');

document.getElementsByTagName('head')[0].appendChild(meta);

You can learn about the meta tag here.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top