Resize event doesn't work in firefox
Hi,
I'm fighting with the following problem. I'm new to jQuery so everything is a bit blurry. I have some programming experience with as3, but jQuery is although better, quite new for me.
The problem is as follows:
I have a css sheet with 3 different body classes .large, .medium, .small which is added at body on resize depending on window.size. Everything is working fine in Safari, Opera and Chrome. Only firefox is what kills me now.
- The code:// JavaScript Document
function checkWindowSize() {
var width = $(window).width(),
new_class = width > 1800 ? 'large' :
width > 1280 ? 'medium' :
width > 0 ? 'small' : '';
alert("resizing")
$(document.body).removeClass('large medium small').addClass(new_class);
}
$(window).resize(checkWindowSize);
$(document).ready(checkWindowSize);
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>Untitled Document</title>
- <script src="js/jquery-1.5.min.js" type="text/jscript"></script>
- <script src="js/resize.js" type="text/jscript"></script>
- <link href="style/layout.css" rel="stylesheet" type="text/css" media="all" />
- </head>
- <body>
- <div id="page_wrapper">
- <div id="menu_wrapper">
- <div id="menu_container">
- <ul>
- <li><a href="#inspiratie">inspiratie</a></li>
- <li class="blue">/</li>
- <li><a href="#hout">hout</a></li>
- <li class="blue">/</li>
- <li><a href="#kemperink">kemperink</a></li>
- <li class="blue">/</li>
- <li><a href="#contact">contact</a></li>
- </ul>
- <div id="top"></div>
- </div>
- <div id="logo_container">
- <a href=""><img src="images/logo.jpg" alt="Kemperink | Inspirators in Hout" /></a>
- </div>
- </div>
- <div id="content_wrapper">content</div>
- </div>
- </body>
- </html>
-
- #body{margin:auto;font-family:"Helvetica Neue", Arial;height:100%; overflow:auto;}
- /*Sets up content and menu*/
- #page_wrapper{width: 1200px; height:auto; margin:auto;}
- #menu_wrapper{width:1200px; height: 70px; top:0; background:#09F; position:fixed; z-index:2;}
- #content_wrapper{width:1200px; height:5000px; margin-top:70px; z-index:1;}
- .large #page_wrapper {width:1550px;height:5000;margin:auto;}
- .large #menu_wrapper {height:70px;z-index:2;top:0px;position:fixed; background:#FFFFFF; width:1550px}
- .large #content_wrapper{z-index:1;margin-top: 70px;position:absolute;height:5000px;}
- .medium #page_wrapper {width:1250px;height:2500;margin:auto;}
- .medium #menu_wrapper {height:70px; x;z-index:2; top:0px; margin-top:0; padding-top:0; position:fixed; background:#9F0; width:1250px}
- .medium #content_wrapper{z-index:1;margin-top: 70px;position:absolute;height:5000px;}
- .small #page_wrapper {width:1024px;height:2500;margin:auto; min-width:1000px}
- .small #menu_wrapper {height:70px;z-index:2;top:0px;position:fixed; background:#666; width:1000px;}
- .small #content_wrapper{z-index:1;margin-top: 70px;position:absolute;height:5000px;}
Any help would be much appreciated!
Thanks in advance