SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Can anyone tell me whats wrong with this? It works fine but if someone scrolls the page before it's loaded the menu shows up on the wrong place.


    <style type="text/css">
    #divBg{position:absolute; width:100%; top:0; left:0; visibility:hidden; height:85}
    DIV.clSub{position:absolute; top:30; left:0; width:120; visibility:hidden; font-family:arial,helvetica; font-weight:bold; font-size:12px; padding:5px; background-color:f0f0f0; layer-background-color:f0f0f0 }
    DIV.clTop{position:absolute; visibility:inherit; font-family:arial,helvetica; font-weight:bold; font-size:13px; left:100; top:30}
    #divTop0{left:10%; top:5}
    #divTop1{left:23%; top:5}
    #divTop2{left:37%; top:5}
    #divTop3{left:52%; top:5}
    #divTop4{left:66%; top:5}
    #divTop5{left:81%; top:5}
    </style>
    <script type="text/javascript" language="JavaScript">
    /********************************************************************************
    Copyright (C) 1999 Thomas Brattli
    This script is made by and copyrighted to Thomas Brattli at http://www.bratta.com
    ********************************************************************************/
    //Default browsercheck, added to all scripts!
    function checkBrowser(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
    }
    bw=new checkBrowser()
    //Do you want it to move with the page if the user scroll the page?
    var moveOnScroll=false

    numberOfMenus=6//How many menus do you have

    //Do you want to hide all the other submenus when you click a new?
    var hideAll=true

    //How much from top do you want the menu?
    fromTop=170




    /********************************************************************************
    Object constructor
    ********************************************************************************/
    function makeMenuBar(obj,nest,vis){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;
    this.hideIt=b_hideIt; this.showIt=b_showIt
    if((bw.dom || bw.ie4) && vis) this.css.visibility='hidden'
    this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;
    this.go=0
    this.height=bw.ns4?this.css.document.height:this.evnt.offsetHeight
    this.top=b_gettop
    this.obj = obj + "Object"; eval(this.obj + "=this")
    }
    //Get's the top position.
    function b_gettop(){
    var gleft=(n) ? eval(this.css.top):eval(this.css.pixelTop);
    return gleft;
    }
    //The functions for showing and hiding
    function b_showIt(){
    this.css.visibility="visible"
    }
    function b_hideIt(){
    this.css.visibility="hidden"
    }
    /********************************************************************************
    Checking if the page is scrolled, if it is move the menu after
    ********************************************************************************/
    function checkScrolled(){
    if(!oMenu.go)oMenu.css.top=eval(scrolled)+fromTop
    if(bw.ns4) setTimeout('checkScrolled()',30)
    }
    /********************************************************************************
    Inits the page, makes the menu object, moves it to the right place,
    show it..
    ********************************************************************************/
    function menuBarInit(){
    oSub=new Array()
    oTop=new Array()
    for(i=0;i<numberOfMenus;i++){
    oTop[i]=new makeMenuBar('divTop'+i,'divBg')
    oSub[i]=new makeMenuBar('divSub'+i,'divBg.document.divTop'+i,1)
    oSub[i].evnt.onmouseout=evOut;
    }
    //Moving menuBar
    oMenu=new makeMenuBar('divBg')
    scrolled=bw.ns4?"window.pageYOffset":bw.ns5?"0":"document.body.scrollTop"
    oMenu.css.top=eval(scrolled)+fromTop
    oMenu.css.visibility='visible'
    if(moveOnScroll) bw.dom || bw.ie4?window.onscroll=checkScrolled:checkScrolled();

    }

    /********************************************************************************
    Shows and hides the submenus
    ********************************************************************************/

    function evOut(){
    if(bw.ie4 || bw.dom)this.style.visibility='hidden'
    else if(bw.ns4) this.visibility='hidden'
    }
    //Canceling event bubbling in ie
    function ieShow(num){
    if(bw.ie4 || bw.dom){
    oSub[num].showIt()
    window.event.cancelBubble=true
    }
    }
    function extract(num){
    if(hideAll){
    for(i=0;i<oSub.length;i++){
    if(num!=i) oSub[i].hideIt()
    }
    }
    oSub[num].showIt();
    }
    onload=menuBarInit;
    </script>



    Thanks,
    Justin Sampson

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Justin,

    Do you have a url I can look at? I tried cut&pasting the code you gave and all I got was 'object expected'. Since it's a bratta script, I presume it worked at some point. If I can see the page in action, I should be able to help you some.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, the sites is http://www.webdevelopershq.com.
    It's not finished yet though, all it is is the layout.

    Thanks,
    Justin Sampson

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Justin,

    Seems like Bratta forgot to add some resizing If you downloaded the script a while back, I would suggest going back to his site and getting a revised menu script -- one that takes resizing into account.

    You might try placing:
    onload=menuBarInit;
    within the body tag instead of between the script tags.

    But, I don't know that that will really help since the problem is that the position is set in the style tags.

    You might also try resetting the top & left positioning by calculating the window's height & width & using percentages instead of real numbers.

    Ultimately though, the fastest solution would be to check with Bratta or another site such as http://www.dynamicdrive.com and http://www.brainjar.com -- I believe they have the same sort of script.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  5. #5
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Where is the actual menu code????
    Wayne Luke
    ------------


  6. #6
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks Vincent The code is located on http://www.webdevelopershq.com .

    Thanks,
    Justin Sampson


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
  •