The script does not work in IE. How can I fix it?
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>&开发者_开发百科lt;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>
outerWidth
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
精彩评论