I did this for my co-worker, though it’s a rarely used function.
http://www.hedgerwow.com/360/dhtml/dom-ie7-zoom-detector.html
Keep It Simple, Stupid
{ 2007 12 05 }
I did this for my co-worker, though it’s a rarely used function.
http://www.hedgerwow.com/360/dhtml/dom-ie7-zoom-detector.html
Shi Chuan | 10-Jan-08 at 9:37 am | Permalink
Hi, Hedger.
I was always wondering what IE6 programm you use to test IE6? I have a software called Multiple IE which can allow both IE6, IE7 installed. But I found IE6 under Multiple IE doesnt render HTML pages the way stand alone IE6 does. May I know what you guys at Yahoo! or you presonally use to do Multiple IE testing?
Thanks in advance!
SharkD | 17-Apr-08 at 9:18 am | Permalink
Some comments:
Change n%10 to n%5 and n = n - r + 10 to n = n - r + Math.round(r/5)*5.
This catches percentages like 75%, and your code wasn’t catching 110% properly.
Also, there’s no point setting a timeout if the function only gets fired on a window resize (in IE this doesn’t happen every time!!!!). Use an interval instead (or use both). I know an interval is not graceful, but… Also, if you use an interval you can put it within the init function for when the document gets loaded.
SharkD | 17-Apr-08 at 11:00 am | Permalink
I noticed also that in quirksmode, IE7 definitely fires the onresize event each time the page is zoomed. Turn quirksmode off, and it skips the occasional event.
SharkD | 28-Apr-08 at 1:41 pm | Permalink
Some more notes:
Notice that when zooming from 140% to 180%, the onresize
event fires only when it’s 150% and 180%. When zooming from
180% to 140% it only fires when it’s 170% and 140%.
Between 120% and 130% the event never fails to fire.
133th | 25-May-08 at 10:12 am | Permalink
hmm, may you or your co-worker know how to disable page zoom?))
Tuemmel | 19-Jul-08 at 7:01 am | Permalink
The page zoom does not happen in appended Child Nodes by the dom. This is really a disaster.
Dan Strother | 20-Jan-09 at 8:50 am | Permalink
I’ve found a seemingly very reliable way of accurately determining the zoom level in IE7:
var rect = document.body.getBoundingClientRect();
var zoomLevel = Math.round( (rect.right-rect.left)/document.body.clientWidth * 100);
This is accurate to well within 1% on the majority of sites I tested, and works over the whole range of 10%-1000%.