#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Fixed menu stoping at footer


    Dear dev shed community, iím struggling with some problems regarding a fixed menu item. I should mention that iím still a beginner in javascript. Iíve searched the web and found this code on how to stop a fixed menu item for overlapping with the footer :

    Code:
     <script src="(URL address blocked: See forum rules)"></script> 
    <script>   
    function checkOffset() {     
    var a=$(document).scrollTop()+window.innerHeight;     var b=$('#footer').offset().top;     
    if (a<b) {       
    $('#menuC').css('bottom', '0px');     } else {       $('#menuC').css('bottom', (0+(a-b))+'px');
         }   
    }   
    $(document).ready(checkOffset);   $(document).scroll(checkOffset); </script>
    and itís working. Menu stops before the footer. The problems that i have now are:

    1) the menu item, depending on the height of the browser, is not always at the same spot. e.g. if the resolution is 1366 x 768 than the pixels above are almost ok, if the resolution is higher or lower than i need to change the numbers so that the menu stays where it should be. Should i change something on that code to make it compatible for all resolutions or should i put a complete different code that fits my needs best ?

    2) i added this code to one php file where the particular menu item is (just to experiment) but i want it to be everywhere else where the same menu is in use and it seems kinda troublesome to copy-paste it to each php file since there are a lot of them. Is there a way for example to include this code in the css where all the properties for the menu are or something along those lines so that i only have to write it once ?

    Sorry for the long post and please be patient with me.

    Thanks in advance leftycool
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    To answer your second question, if you drop your javascript code into its own file with the extension .js, you can add a <script src="/path/to/that/file.js"></script> tag to your web page(s) without having to copy and paste the code itself.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0
    Thank you. So there is no solution to avoid editing all the php files :-(.
    Anyhow i'll try your recommendation.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    I wouldn't say there is no solution. You can implement any templating system, where your site's theme, including the <head> and all your scripts and whatnot, are contained in a single code snippet that's applied to all your site's pages.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0
    This sounds like more work (not to mention that i have to learn first how to do it) than copying and pasting a few lines in ~30 files
    Well with no solution i meant no easy solution that a beginner like me could do.

IMN logo majestic logo threadwatch logo seochat tools logo