Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12618 closed bug (duplicate)

$(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:

Description

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" "http://www.w3.org/TR/html4/loose.dtd">

-->

<html> <head> <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) {

addWidth();

});

</script>

<title>Window Width Problem in jQuery</title> </head> <body> <h1>Window Width Problem in jQuery</h1> <p id="wdResult"></p> </body> </html>

You will see

Window Width Problem in jQuery window width: 0 document.compatMode: BackCompat

Change History (1)

comment:1 Changed 7 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Duplicate of #12388.

Note: See TracTickets for help on using tickets.