SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    advance javascript????

    heya all, iv just bin given a javascript proj for my work. now i dont know javascript- and would like to understand the code. I know what the code does when its run- but not the code itself.

    here is a sample of the code:
    Code:
    function getDHTMLObj(docName, objName) {
    	if 	(theBrowser.hasW3CDOM) {
    		return eval(docName + '.getElementById("' + objName + '").style');
    	} else {
    		return eval(docName + theBrowser.DHTMLRange + '.' + objName + theBrowser.DHTMLStyleObj);
    	}
    }
    function getDHTMLObjTop(theObj) {return (theBrowser.code == "MSIE") ? theObj.pixelTop : theObj.top;}
    function getDHTMLObjHeight(docName, objName) {
    	if 	(theBrowser.hasW3CDOM) {
    		return parseInt(eval(docName + '.getElementById("' + objName + '").offsetHeight'),10);
    	} else {
    		return eval(docName + theBrowser.DHTMLRange + '.' + objName + theBrowser.DHTMLDivHeight);
    	}
    }
    function getDHTMLImg(docName, objName, imgName) {
    	if 	(document.layers) {
    		return getDHTMLObj(docName, objName).document.images[imgName];
    	} else {
    		return eval(docName + '.images.' + imgName);
    }
    }
    is this advanced javascript??? ive looked on w3 schools with javascript tutorials and there nothing like the code ive bin given. w3 schools and other javascript tutorials tend to be more on the html side, is ther ny tutorials out there which relate the way im doin this?? please provide links- thanks

  2. #2
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This actually looks like a pretty old script, but some of it's missing. Some place there has to be code to setup the object "theBrowser" and set its properties, such as "hasW3CDOM".

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not only is it old, but also quite bad, since it uses eval, and that could easily be avoided.


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
  •