Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Location
    Mauritius
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Jquery error in firefox

    Hi all - I have written this whichg works well in chrome and ie :

    $(document).ready(function(){

    if (/Android|BlackBerry|iPhone|iPad|iPod|webOS/i.test(navigator.userAgent) === false) {
    resizeWindow();
    $(window).resize(resizeWindow);

    function resizeWindow() {
    var ww = $(window).width();
    var bh = $(document).height();
    var wh = $(window).height();
    featureHeight = wh - 20;
    $('#slider').css({'height':featureHeight+'px'});
    }

    }


    });


    But in firefox i get this error :
    ReferenceError: resizeWindow is not defined

    resizeWindow();


    Can't figure out what I have done wrong - any help please.

    //Sam

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Move the resizeWindow out of the function scope of $(document).ready
    Code:
    $(document).ready(function(){
       if (/Android|BlackBerry|iPhone|iPad|iPod|webOS/i.test(navigator.userAgent) === false) {
          resizeWindow();
          $(window).resize(resizeWindow);
       }
    });
    
    function resizeWindow() {
       var ww = $(window).width();
       var bh = $(document).height();
       var wh = $(window).height();
       featureHeight = wh - 20;
       $('#slider').css({'height':featureHeight+'px'});
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •