2

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>&nbsp;</td><td id=t3>&nbsp;</td><td id=t2>&nbsp;</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>
Astraport
  • 1,239
  • 4
  • 20
  • 40
  • *"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 May 10 '11 at 18:37
  • __[IE8]__ `alert(window.outerWidth);` <-- returns undefined. – Doug Chamberlain May 10 '11 at 18:42
  • >>[IE8] alert(window.outerWidth); <-- returns undefined. How i can replace window.outerWidth for IE? – Astraport May 10 '11 at 18:56

3 Answers3

3

outerWidth is supported by IE, but since from the IE9.

Replacement

pmaruszczyk
  • 2,157
  • 2
  • 24
  • 49
2

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
Tom Chandler
  • 642
  • 3
  • 9
0

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
Doug Chamberlain
  • 11,192
  • 9
  • 51
  • 91