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 4 of 4
  1. #1
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts

    windowWidth undefined in IE

    Why do i get windowWidth undefined with this in IE
    works fine in NN/FF

    function WindowWidthandHeight() {
    var windowHeight = 0;
    var windowWidth = 0;
    var centerLag = action[1];
    if (typeof(window.innerHeight) == 'number') {
    windowHeight = window.innerHeight;
    windowWidth = window.innerWidth;
    }
    else {
    if (document.documentElement && document.documentElement.clientHeight) {
    windowHeight = document.documentElement.clientHeight;
    windowWidth = document.documentElement.clientWidth;
    }
    else {
    if (document.body && document.body.clientHeight) {
    windowHeight = document.body.clientHeight;
    windowWidth = document.bodyclientWidth;
    }
    }
    alert (windowWidth);
    alert (windowHeight);
    }
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Code:
    function zxcWWHS(){
     var winww,zxcwh,zxcsl,zxcst,zxcwc;
     if (window.innerHeight){
      zxcCur='pointer';
      zxcwh=window.innerHeight-20;
      zxcww=window.innerWidth-20;
      zxcsl=window.pageXOffset;
      zxcst=window.pageYOffset;
     }
     else if (document.documentElement.clientHeight){
      zxcCur='hand';
      zxcwh=document.documentElement.clientHeight;
      zxcww=document.documentElement.clientWidth;
      zxcsl=document.documentElement.scrollLeft;
      zxcst=document.documentElement.scrollTop;
     }
     else if (document.body.clientHeight){
       zxcwh=document.body.clientHeight;
       zxcww=document.body.clientWidth;
       zxcsl=document.body.scrollLeft;
       zxcst=document.body.scrollTop;
      }
     zxcwc=Math.round(zxcww/2);
     return [zxcww,zxcwh,zxcsl,zxcst];
    }
    
    function zxcBdyWH(){
    var x,y;
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
    	x = document.body.scrollWidth;
    	y = document.body.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
    	x = document.body.offsetWidth;
    	y = document.body.offsetHeight;
    }
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Im nut shuer What you are trying to say with that ??

    scrollTop & scrollLeft ???

    My question was simply why i get the windowWidth undefined in IE
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    put what you dont want in a safe place
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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