Skip to main content

Bug Tracker

Side navigation

#12618 closed bug (duplicate)

Opened September 27, 2012 01:38AM UTC

Closed September 27, 2012 01:42AM UTC

$(window).width() incorrect in IE6 and IE9 with jQuery 1.8.1

Reported by: Dpk Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.1
Keywords: Cc:
Blocked by: Blocking:

In IE6 and IE9 (not tested with IE8) when there browser is in the compatibility mode $(window).width() returns 0.

When the browser is in the standards mode $(window).width() works correctly.

NOT reproduced with jsfiddle because you can't change the DOCTYPE.

Use this NB: DOCTYPE is commented out

<!-- <!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01 TransitionalEN" "">




<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript" src="jquery-1.8.1.js"></script>

<script type="text/javascript">

function addWidth() {

var ww = $(window).width();

$("#wdResult").text("window width: " + ww + " document.compatMode: " + document.compatMode);


$(window).ready(function(e) {




<title>Window Width Problem in jQuery</title>



<h1>Window Width Problem in jQuery</h1>

<p id="wdResult"></p>



You will see

Window Width Problem in jQuery

window width: 0 document.compatMode: BackCompat

Attachments (0)
Change History (1)

Changed September 27, 2012 01:42AM UTC by dmethvin comment:1

resolution: → duplicate
status: newclosed

Duplicate of #12388.