www.webdeveloper.com
Results 1 to 14 of 14

Thread: Best way to make sure every page has the same menu?

  1. #1
    Join Date
    Apr 2010
    Posts
    24

    Best way to make sure every page has the same menu?

    Hi everyone.

    I'm building a website that's going to be hosted on a Linux server, and I want every page on it to display the same CSS pull-down menu on the left-hand side. I was just wondering what the standard method is that web developers usually use to make things like this happen.

    Someone on here suggested to me before that I could do it by placing the code for the menu in a Javascript file and then having every page call that file. But that doesn't seem like a great method to me, because some people disable Javascript. Through browsing the web, I learned that using PHP includes might be a better option, since the PHP code is compiled server-side, so there wouldn't be the issue of someone having Javascript disabled. But then, every page on the site would have to be a php file, meaning the server would have to compile it every time someone looked at the page. And wouldn't that slow down the server? I don't have a dedicated server, I'm renting space from a hosting company with one of their cheaper plans.

    So I was just wondering, how do most web-developers handle this problem? Any insights would be helpful. Thanks.

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    To a large extent imo you have already answered your own question.

    If a website uses PHP then I would use php include files for the menus.

    If everything was done client side only, then I would put the code to generate the menus in an external javascript file.

    Imo, the percentage of users who have javascript disabled is most probably miniscule. But for those that do, you can include <noscript> in your html and politetly encourage users to switch on their javascript.

    With php processing, imo the time it takes the php engine to process a web page before sending it down the "pipe" to the browser is most probably in the order of milli or micro seconds and not worth worrying about.
    Last edited by tirna; 07-02-2010 at 07:16 AM.

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    IMO , I don't use JavaScript and if you use the NOSCRIPT element in that way I'm leaving your site, never to return and shaking my head in disbelief. The number of people who choose not to use JavaScript is vast. The number who do not use it because of some disability is huge.

    PHP doesn't slow things down that much but if you are worried then mark up all your pages in XHTML 1.0 Strict but omitting the menus. Then provide an XSLT Stylesheet that transforms the documents to HTML 4.01 Strict and adds the menu. You would only need to edit the stylesheet to make whatever changes you want across the site. You'll want to keep as much in the stylesheet and as little in the individual files as possible. From there you could either post everything as it is--modern browsers will handle the rest if you save the files with an XML extension--or you could run the transformations yourself in batch mode and then upload the lot.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  4. #4
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by Charles View Post
    The number of people who choose not to use JavaScript is vast.
    I am not convinced that is true.

    In my experience over the years, I have never had anyone (end user or client) complain to me that a website I have built is inaccessible or not functioning properly for them because it uses javascript.

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    I've never once complained, I've always just walked away shaking my head. The percentages are dropping but at 5% that's still a huge number ( http://www.w3schools.com/browsers/browsers_stats.asp ). And if your web site is governed by accessibility laws, say you have a commercial site in the US, then you have one huge liability if your sire relies upon JavaScript.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Mar 2010
    Posts
    2,803
    I see those js stats are for 2008 and so could be way out of date by now.

    Below those stats, the w3schools also mention that those stats could be unreliable and should not be relied on.

    My suspicion is that less than 5&#37; of users have javascript off for any reason nowadays. But even if it is still at 5%, that number is still way too small for me to waste time worrying about, unless a client specifically requests their website to be fully functional without js. In that case I would decline to even give a price quote as nowadays I can pick and choose which jobs I take on.

    But if someone has a large number of non js users visiting their website for some reason and they must be catered for, I have no issue with that at all and so in those cases you obviously would have to have a plan B for non js users. Luckily I am not in that position
    Last edited by tirna; 07-02-2010 at 11:37 PM.

  7. #7
    Join Date
    Jan 2009
    Posts
    3,346
    unless a client specifically requests their website to be fully functional without js
    All US government sites and vendors that provide services to the government must have sites that are fully functional without javascript as part of the accessibility requirements.
    Last edited by criterion9; 07-03-2010 at 08:30 AM.

  8. #8
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by criterion9 View Post
    All government sites and vendors that provide services to the government must have sites that are fully functional without javascript as part of the accessibility requirements.
    I'm not convinced that applies in every country.

  9. #9
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by tirna View Post
    I'm not convinced that applies in every country.
    I meant to say "All US Government". Apologies.

  10. #10
    Join Date
    Mar 2010
    Posts
    2,803
    if you say so

  11. #11
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    No, but since it's an accessibility issue it would be quite cruel and inconsiderate to ignore. Kind of like running down people with white canes because there aren't that many of them. Or like refusing to provide accessible toilets in your shop because you are logging enough flushes as it is.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  12. #12
    Join Date
    Jul 2010
    Location
    Winnipeg, MB, CA
    Posts
    10
    Use a menu.include.php file with just the menu information

  13. #13
    Join Date
    Aug 2007
    Posts
    3,767
    Quote Originally Posted by tirna View Post
    My suspicion is that less than 5% of users have javascript off for any reason nowadays.
    Obviously it depends on your audience. The people you build websites for probably don't know much about the web themselves (because you are making their website not you), therefore they are far less likely to have JavaScript disabled than, let's say, developers.

    Anyway, there are very few occasions where it is a pain to get something to work without JavaScript also. The most common uses, validation and visual displays, either have to be replicated or aren't necessary in the first place.

    And I would be astounded if any government had such lax accessibility guidelines that the site didn't work without JavaScript. Certainly in the real world, no government could exclude any minority, however small, so it must be rare virtually too.
    Great wit and madness are near allied, and fine a line their bounds divide.

  14. #14
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by Declan1991 View Post
    Obviously it depends on your audience.
    I would imagine that the w3schools website, where the 95&#37; figure for users with javascript enabled in their browsers comes from, has a very wide cross-section of users visiting the website.

    So if w3schools says that in 2008, 95% of users had javascript enabled, notwithstanding their disclaimer, that is good enough for me .

    Since I am essentially retired, I can now pick and choose which jobs I quote for and take on if given them.

    If a project specification includes having to cater for non js enabled browsers, and I haven't seen one yet that does, then I don't even waste my time quoting for the job.

    And so far in my experience, none of my clients have ever complained to me about their clients complaining to them about their websites not supporting non js enabled browsers.

    So for me personally, non js enabled browsers is not an issue at all.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles