SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two javascript errors, but page works fine?

    Hey all...I'm working on something for a friend of mine. He's using a resize "onload" window script (code below). It throws two errors which I can't figure out how to fix. Can someone take a look here and help me out please?

    Error 1: Char 1, line highlighted in red
    "syntax error"

    Error 2: Char 4, line highlighted in blue
    "d.all.coverlayer.style is null or not an object"

    Thanks in advance for any help you can give me.

    Code:
    	var d = document;
    	var isNav = false, isNS6 = false, isIE = false;
    	
    	if(d.layers) {
    		isNav = true;
    	  var range = "";
    	  var styleObj = "";
    		} 
    	else if (d.all) {
    	  isIE = true;
    	  range = "all.";
    	  styleObj = ".style";
    		} 
    	else if(d.getElementById) {
    		isNS6 = true;
    	  var range = "getElementById('";
    	  var styleObj = "').style";
    	}
    	
    	function sizegoal(iw,ih) {
    		if(isIE) {
    			var cx = parseInt(top.document.body.clientWidth);
    			var cy = parseInt(top.document.body.clientHeight);
    			}
    		else {
    			var cx = (window.innerWidth);
    			var cy = (window.innerHeight);	
    			}
    		if (cx < iw-10) {resizeBy(((iw-cx)/8),0);}
    		else if(cx > iw+10) {resizeBy(((iw-cx)/8),0);}
    		else {resizeBy(iw-cx,0);}
    		
    		if (cy < ih-10) {resizeBy(0,((ih-cy)/8));}
    		else if (cy > ih+10) {resizeBy(0,((ih-cy)/8));}
    		else {resizeBy(0,ih-cy);}
    		
    		if((cx != iw) || (cy != ih)) {
    			setTimeout('sizegoal('+iw+','+ih+')','20');
    			}
    		else {
    			if(isIE) {if(document.all)for(var i in document.links)document.links[i].onfocus=document.links[i].blur;}
    			hide('coverlayer');
    			}
    		}
    		
    	function getObject(obj) {
    		var theObj = eval("document." + range + obj + styleObj);
    		return theObj;
    	}
    		
    	function shiftTo(obj, x, y) {
    		if (isNS6) {
    			obj.left = x;
    			obj.top = y;
    			}
    		else if(isIE) {
    			obj.pixelLeft = x;
    			obj.pixelTop = y;
    			} 
    		else {
    			obj.moveTo(x,y);
    			}
    		}
    	
    	function hide(layername) {
    		if(isIE)
    			eval("d.all['"+layername+"'].style.visibility = 'hidden'");
    		else if(isNS6) {
    			eval("d.getElementById('"+layername+"').style.visibility = 'hidden'");
    			}
    		else {
    			eval("d."+layername+".visibility = 'hide'");
    			}
    		}
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you had an extra bracket

    PHP Code:

        
    var document;
        var 
    isNav falseisNS6 falseisIE false;
        
        if(
    d.layers)
        {
            
    isNav true;
            var 
    range "";
            var 
    styleObj "";
        } 
        else if (
    d.all)
        {
            
    isIE true;
            
    range "all.";
            
    styleObj ".style";
        }
        else if(
    d.getElementById) {
            
    isNS6 true;
          var 
    range "getElementById('";
          var 
    styleObj "').style";
        }
        
        function 
    sizegoal(iw,ih)
        {
            if(
    isIE)
            {
                var 
    cx parseInt(top.document.body.clientWidth);
                var 
    cy parseInt(top.document.body.clientHeight);
            }
            else
            {
                var 
    cx = (window.innerWidth);
                var 
    cy = (window.innerHeight);    
            }

            if     (
    cx iw-10)     resizeBy(((iw-cx)/8),0);
            else if(
    cx iw+10)    resizeBy(((iw-cx)/8),0);
            else             
    resizeBy(iw-cx,0);
            
            if      (
    cy ih-10)     resizeBy(0,((ih-cy)/8));
            else if (
    cy ih+10)    resizeBy(0,((ih-cy)/8));
            else            
    resizeBy(0,ih-cy);
            
            if((
    cx != iw) || (cy != ih))
            {
                
    setTimeout('sizegoal('+iw+','+ih+')','20');
            }
            else
            {
                if(
    isIE)
                {
                    if(
    document.all)for(var i in document.links)document.links[i].onfocus=document.links[i].blur;
                    
    hide('coverlayer');
                }
            }
            
        function 
    getObject(obj)
        {
            var 
    theObj = eval("document." range obj styleObj);
            return 
    theObj;
        }
            
        function 
    shiftTo(objxy)
        {
            if (
    isNS6)
            {
                
    obj.left x;
                
    obj.top y;
            }
            else if(
    isIE)
            {
                
    obj.pixelLeft x;
                
    obj.pixelTop y;
            } 
            else
            {
                
    obj.moveTo(x,y);
            }
        
        function 
    hide(layername)
        {
            if(
    isIE)    eval("d.all['"+layername+"'].style.visibility = 'hidden'");
            else if(
    isNS6)     eval("d.getElementById('"+layername+"').style.visibility = 'hidden'");
            else         eval(
    "d."+layername+".visibility = 'hide'");
        } 

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    extra bracket where?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just checked for the extra bracket and i cannot see it, I dunno what I was looking at ealier

    but try

    PHP Code:
    var document;
    var 
    isNav falseisNS6 falseisIE false;

    alert(isNav '\n' isNS6 '\n' isIE
    PHP Code:
            var isNav falseisNS6 falseisIE true;

            if(
    isIE)     alert ('ie');
            else if(
    isNS6)    alert ('netscape');
            else         
    alert ('else'); 
    Last edited by Andrew-J2000; Apr 17, 2002 at 08:13.

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Andrew....anyone else?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone else have input on this?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


Bookmarks

Posting Permissions

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