There is a script that changes the page template depending on the user's monitor screen resolution. However, it does not work in IE. Advise how to fix it, please.
<body>
<table id="mt" align="center" >
<tr>
<td colspan=3 id=top>{{head}}</td></tr><tr><td id=t1> </td><td id=t3> </td><td id=t2> </td></tr><tr>
<td id=1eft valign=top>{{left}}</td>
<td id=content><h1>[*pagetitle*]</h1>[*content*]</td>
<td id=right>{{right}}</td></tr>
<tr><td id=ft colspan=3>{{foot}}</td></tr>
</table><script>if (window.outerWidth>1440) {a='1440px';} else {a='auto';}document.getElementById("mt").style.width = a;</script></body>
There is a script that changes the page template depending on the user's monitor screen resolution. However, it does not work in IE. Advise how to fix it, please.
<body>
<table id="mt" align="center" >
<tr>
<td colspan=3 id=top>{{head}}</td></tr><tr><td id=t1> </td><td id=t3> </td><td id=t2> </td></tr><tr>
<td id=1eft valign=top>{{left}}</td>
<td id=content><h1>[*pagetitle*]</h1>[*content*]</td>
<td id=right>{{right}}</td></tr>
<tr><td id=ft colspan=3>{{foot}}</td></tr>
</table><script>if (window.outerWidth>1440) {a='1440px';} else {a='auto';}document.getElementById("mt").style.width = a;</script></body>
Share
Improve this question
asked May 10, 2011 at 18:34
AstraportAstraport
1,2574 gold badges21 silver badges40 bronze badges
3
- "The script does not work in IE." How does it not work? What happens on IE? Nothing? The templates get the wrong size? You see error messages in the script console? (Hint) Everything turns a lovely shade of fucshia? ;-) – T.J. Crowder Commented May 10, 2011 at 18:37
-
[IE8]
alert(window.outerWidth);
<-- returns undefined. – Doug Chamberlain Commented May 10, 2011 at 18:42 - >>[IE8] alert(window.outerWidth); <-- returns undefined. How i can replace window.outerWidth for IE? – Astraport Commented May 10, 2011 at 18:56
3 Answers
Reset to default 3outerWidth
is supported by IE, but since from the IE9.
Replacement
Not all browsers have the window.outerWidth and window.outerHeight properties. Geek Daily has a good post on cross-browser window size detection. I'd suggest looking there. As an example, here's what I get in each browser on a desktop with 1280x1024 resolution.
Chrome
window.outerWidth
1288
document.body.offsetWidth
1264
document.documentElement.offsetWidth
1280
Firefox
window.outerWidth
1288
document.body.offsetWidth
1238
document.documentElement.offsetWidth
1264
IE7 Doctype Defined
window.outerWidth
undefined
document.body.offsetWidth
1260
document.documentElement.offsetWidth
1260
IE7 No Doctype/Quirks Mode
window.outerWidth
undefined
document.body.offsetWidth
1260
document.documentElement.offsetWidth
1280
I see a few other problems
- All of your attribute values should be in quotes. for example.
id="value"
- you have LEFT spelled 1(number 1)eft