Thread: Javascript help

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    400
    Rep Power
    13

    Javascript help


    Hi, I didn't know why this script doesn't work. I presume it basically reposition my layer when screen resolution or page resize occurs.

    PHP Code:

    var activeSub=0;
    var 
    SubNum=0;

    function 
    reDo(){ window.location.reload() }
        
    window.onresize reDo;


        
    //Define global variables

            
    var timerID null;
            var 
    timerOn false;
            var 
    timecount 200;
            var 
    what null;
            var 
    newbrowser true;
            var 
    check false;

            function 
    init(){
            
    //  alert ("Running Init");
              
    if (document.layers) {
                          
    //  alert ("Running Netscape 4");
                            
    layerRef="document.layers";
                            
    styleSwitch="";
                            
    visibleVar="show";
                
    screenSize window.innerWidth;
                
    what ="ns4";


              }else if(
    document.all){
                          
    //  alert ("Running IE");
                            
    layerRef="document.all";
                            
    styleSwitch=".style";
                            
    visibleVar="visible";
                
    screenSize document.body.clientWidth 18;
                
    what ="ie";

              }else if(
    document.getElementById){
                          
    //  alert ("Running Netscape 6");
                            
    layerRef="document.getElementByID";
                            
    styleSwitch=".style";
                            
    visibleVar="visible";
                
    what="moz";
              
              }else{
                  
    //alert("Older than 4.0 browser.");
                
    what="none";
                
    newbrowser false;
              }
            
            
    check true;
               }

        
    // Turns the layers on and off
            
    function showLayer(layerName){
                if(
    check){
                    if (
    what =="none"){
                        return;
                        }
                    else if (
    what == "moz"){
                        
    document.getElementById(layerName).style.visibility="visible";
                        }
                    else{
                      eval(
    layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
                      }
             }
                else {
    // alert ("Please wait for the page to finish loading.");
                    
    return;}
            }

            function 
    hideLayer(layerName){
                if(
    check){
                    if (
    what =="none"){
                        return;
                        }
                    else if (
    what == "moz"){
                        
    document.getElementById(layerName).style.visibility="hidden";
                        }
                    else{
                      eval(
    layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
                    }
            
                }
                else {
    // alert ("Please wait for the page to finish loading.");
                    
    return;}
            }


            function 
    hideAll(){
                    
    hideLayer('layer1');
                    }


            function 
    startTime() {
                if (
    timerOn == false) {
                    
    timerID=setTimeout"hideAll()" timecount);
                    
    timerOn true;

                }

            }


            function 
    stopTime() {
                if (
    timerOn) {
                    
    clearTimeout(timerID);
                    
    timerID null;
                    
    timerOn false;
                }
            }

            function 
    onLoad(){
                
    init();
                
                } 
    But it doesn't work. Am I doing wrong anywhere? Here's my style:

    PHP Code:

    #layer1 { background-color : #666666;
       
    layer-background-color #666666;
       
    width 138px;
       
    top 99px;
       
    left 973px;
       
    position absolute;
       
    z-index 90;
       
    visibility hidden;

  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Which part of it doesn't work? What's it not doing?

IMN logo majestic logo threadwatch logo seochat tools logo