Results 1 to 3 of 3

Thread: Floating Top Bar script modification

  1. #1
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Floating Top Bar script modification

    Hi
    I found this script and it seems to have everything i need.

    Floating Top Bar script
    http://www.dynamicdrive.com/dynamicindex17/floatbar.htm

    However, i only want this to appear after the user has scrolled down the page a certain amount.
    In a similar way to this page on about.com (view in IE)
    http://javascript.about.com/od/refer...rms=javascript


    Any idea if i can adapt this script to perform like this?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Give these modifications a try - In the configuration area for the script, add this variable (highlight red):

    Code:
    var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
    var startX = 30 //set x offset of bar in pixels
    var startY = 5 //set y offset of bar in pixels
    var tLimit = 175 //set vertical scroll trigger point for bar's appearance/disappearance, use 0 for always visible
    var verticalpos="fromtop" //enter "fromtop" or "frombottom"
    Add this function (just above function staticbar):

    Code:
    function restrictbar(){
    pageScroll=typeof pageYOffset!=='undefined'? pageYOffset : iecompattest().scrollTop
    document.getElementById("topbar").style.display=pageScroll>=tLimit? "block" : "none"
    setTimeout("restrictbar();", 200)
    }
    Add to function staticbar, like so (addition red):

    Code:
    function staticbar(){
    	if (tLimit) restrictbar();
    	barheight=document.getElementById("topbar").offsetHeight
    	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
    	var d = document;
    	function ml(id){
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Your a genius...
    That has worked brillaintly.

    Many thanks

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
  •