This script performs fine in all browsers except IE...

Discussion in 'JavaScript' started by Sleeping Troll, Jul 14, 2009.

  1. #1
    This is the script:
    function resize(){
    if (window.innerWidth){ //if browser supports window.innerWidth
    Dimensions.width=window.innerWidth;
    Dimensions.height=window.innerHeight;
    }
    else if (document.all){ //else if browser supports document.all (IE 4+)
    Dimensions.width=document.body.clientWidth;
    Dimensions.height=document.body.clientHeight;
    }
    Zmax=Dimensions.width*2;
    Xmax=Dimensions.width-400;
    Ymax=Dimensions.height-150;
    $('content').style.width=Dimensions.width;
    $('content').style.height=Dimensions.height;
    $('banner').style.display='block';
    $('banner').style.top=0+'px';
    $('banner').style.left=0+'px';
    $('banner').style.width=Dimensions.width;
    $('logo').style.width=325+'px';
    $('logo').style.height=90+'px';
    $('panelBanner').style.top=0+'px';
    $('panelBanner').style.left=325+'px';
    $('panelBanner').style.width=Dimensions.width-325+'px';
    $('panelBanner').style.height=90+'px';
    $('container').style.top=140+'px';
    $('container').style.left=10+'px';
    $('container').style.width=Xmax+'px';
    $('container').style.height=Ymax+'px';
    $('panelmenuMain').style.top=100+'px';
    $('panelmenuMain').style.left=10+'px';
    $('panelmenuMain').style.width=Xmax+'px';
    $('panelmenuMain').style.height=100+'px';
    $('panelmenuUser').style.top=100+'px';
    $('panelmenuUser').style.left=Dimensions.width-377+'px';
    $('panelmenuUser').style.width=370+'px';
    $('panelmenuUser').style.height=100+'px';
    $('panelMain').style.top=140+'px';
    $('panelMain').style.left=Dimensions.width-377+'px';
    $('panelMain').style.width=370+'px';
    $('panelMain').style.maxHeight=Ymax-250+'px';
    $('panelmenuWidget').style.top=Dimensions.height-255+'px';
    $('panelmenuWidget').style.left=Dimensions.width-377+'px';
    $('panelmenuWidget').style.width=370+'px';
    $('panelmenuWidget').style.height=100+'px';
    $('panelWidget').style.top=Dimensions.height-215+'px';
    $('panelWidget').style.left=Dimensions.width-377+'px';
    $('panelWidget').style.width=370+'px';
    $('panelWidget').style.maxHeight=200+'px';
    OrbBaseRadius=Xmax/50;
    Xmin=0;
    Ymin=0;
    Zmin=0;
    Zscreen=Zmax*.25;
    Zeye=Zmax*1.00;
    InitialVelocity=1;
    widthfactorbannerPanel=Math.floor((Dimensions.width-300)/392);
    heightfactorpanelMain=Math.floor($('panelMain').style.height/234)
    }
    The error is: "invalid argument line 164 character 2 (the line in red).
    The line in red is the only one that throws an error, what's up with that?
    This is the site: http://orbzorbz.com
     
    Sleeping Troll, Jul 14, 2009 IP
  2. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    OK problem is for some reason the client height is returning an erroneous value, it seems to be a matter of timing.
     
    Sleeping Troll, Jul 14, 2009 IP
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    is "container" visible at the time? by that i mean, its in the dom, its got visibility: visible and display is block? IE can be dodgy with hidden elements. it also fails to inherit a height correctly at times and is not always consistent on the computed height, if any. in the past i've had to even move an element off-screen then make it visible and then get the width/height...

    another thing you can check is - make sure your func is within your onload / (dom)ready handler and if needed, delay its execution further via a setTimeout etc.
     
    dimitar christoff, Jul 14, 2009 IP