Skip to main content

Bug Tracker

Side navigation

#12594 closed bug (duplicate)

Opened September 22, 2012 11:55PM UTC

Closed September 23, 2012 12:07AM UTC

Last modified September 23, 2012 03:24PM UTC

width() returns float when zoomed

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description says that width() is supposed to return integers only, but in Chrome and Firefox it is returning floating-point values if the page is zoomed. IE does not exhibit this problem for me.


<!doctype html>
<script src='jquery-1.8.2.min.js'></script>
  $(document).ready(function() {
    setInterval(function() {
    }, 30);
  <div id='div' style='width:300px; height:300px; border: solid'></div>

In chrome & firefox, if I zoom in/out (ctrl+ and ctrl-), I expect the number displayed to stay 300, but instead it changes to 299.3333330154419, 299.9909906387329, 300.5454545021057, etc.

  • jquery 1.8.2
  • win7 64bit
  • chrome 22.0.1229.64 beta-m
  • firefox 14.0.1
Attachments (0)
Change History (6)

Changed September 23, 2012 12:03AM UTC by comment:1

Sorry, I didn't see the note about using jsFiddle until after I posted. Here's the same sample:

Changed September 23, 2012 12:07AM UTC by rwaldron comment:2

resolution: → duplicate
status: newclosed

Duplicate of #11298.jQuery only supports use in 100% zoom

Changed September 23, 2012 12:49AM UTC by comment:3

Is there a canonical place where the "only supports 100% zoom" policy is documented? It is a surprise to me and I've been using jquery for years. I'm also unable to find it mentioned outside of passing references in bugs.

Are there any suggested workarounds other than just popping up a warning like "sorry your zoom level is not supported?"

Changed September 23, 2012 01:07AM UTC by rwaldron comment:4

That's exactly the problem, there is no way to know if the viewport is zoomed. It doesn't need to be "canonically documented" as it's not a jQuery issue.

Changed September 23, 2012 02:43AM UTC by comment:5

I had no way to know jQuery wouldn't work with zoom, though. It isn't written down anywhere outside of bugs. I would have been less confused (and wouldn't have bothered to open this bug) if the API docs mentioned that zoom led to undocumented behavior. That said, I would understand if this is deemed too esoteric an issue to warrant mentioning in the docs, though.

I also would have been helped by knowing that other methods of getting the width (such as .css(width) and .clientWidth) work correctly when zooming in chrome & FF.

Changed September 23, 2012 03:24PM UTC by mikesherov comment:6

I opened this ticket against the docs to see if they'll add a note about zoom not working well: