SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Uppsala
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help required: adding support for newer browsers through getElementById

    I want to add to an existing script (not written by me) so it works for all new browsers and not just IE (and old netscape-browsers):

    old script:

    /************************************************************************************
    Browsercheck
    ************************************************************************************/
    var n = (document.layers) ? 1:0;
    var ie = (document.all) ? 1:0;
    var browser=((n || ie) && parseInt(navigator.appVersion)>=4)

    /************************************************************************************
    Making cross-browser objects
    ************************************************************************************/
    function makeMenu(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')
    this.ref=(n) ? eval(nest+'document.'+obj+'.document'):eval('document');
    this.height=n?this.ref.height:eval(obj+'.offsetHeight')
    this.x=(n)? this.css.left:this.css.pixelLeft;this.y=(n)? this.css.top:this.css.pixelTop;
    this.hideIt=b_hideIt; this.showIt=b_showIt; this.vis=b_vis; this.moveIt=b_moveIt
    return this
    }
    function b_showIt(){this.css.visibility="visible"}
    function b_hideIt(){this.css.visibility="hidden"}
    function b_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}
    function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}


    Since I don't normally dabble with Javascript I would appreciate some help with rewriting the function makeMenu to use getElementById:

    /************************************************************************************
    Browsercheck
    ************************************************************************************/
    var wwwc = (document.getElementById) ? 1:0;
    var n = (document.layers) ? 1:0;
    var ie = (document.all) ? 1:0;
    var browser=(((n || ie) && parseInt(navigator.appVersion)>=4) || wwwc)
    /************************************************************************************
    Making cross-browser objects
    ************************************************************************************/
    function makeMenu(obj,nest){
    if (wwwc)
    {
    //Need your help with this section
    }
    else{

    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')
    this.ref=(n) ? eval(nest+'document.'+obj+'.document'):eval('document');
    this.height=n?this.ref.height:eval(obj+'.offsetHeight')
    this.x=(n)? this.css.left:this.css.pixelLeft;this.y=(n)? this.css.top:this.css.pixelTop;
    this.hideIt=b_hideIt; this.showIt=b_showIt; this.vis=b_vis; this.moveIt=b_moveIt
    return this
    }
    }
    function b_showIt(){this.css.visibility="visible"}
    function b_hideIt(){this.css.visibility="hidden"}
    function b_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}
    function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}

    Thank you in advance
    Last edited by birken; Nov 29, 2004 at 08:35.

  2. #2
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Uppsala
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ttt


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
  •