Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New to the CF scene
    Join Date
    Nov 2005
    Location
    Washington State, US
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Newbie here, simple question I think...

    Hi all,

    Here's some code that contains a part that I don't understand and that I haven't been able to find an explaination for.

    In this code for a simple list, I don't understand the usage of the "#". I've gone to several forums and the W3 school page to search, but LOL you can't search for #.
    What does the # stand for here?

    <ul id="navigation">
    <li id="youarehere"><a href="#">Home</a></li>
    <li><a href="#">Products</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact Us</a></li>
    </ul>

  • #2
    Regular Coder 2reikis's Avatar
    Join Date
    Nov 2005
    Location
    California
    Posts
    167
    Thanks
    17
    Thanked 13 Times in 13 Posts

    fragment identifiers

    http://www.w3.org/TR/REC-html40/intr...l#fragment-uri

    The link above has some information on fragment identifiers. The pound sign (#) is used to identify a jump to a pre-defined section of a page rather than displaying the page from the top. Usually, the form used is (/somepage.htm#jump_here). In the case of the code you included in your post, it performs no function at all other than as a place holder for you to fill in the blanks. Basically it's saying "put the right information here"

  • #3
    Regular Coder Rappa's Avatar
    Join Date
    Nov 2005
    Location
    LI
    Posts
    356
    Thanks
    21
    Thanked 9 Times in 9 Posts
    Its like, a decoy link for a URL for yourself that dosn't point anywhere, Until you think of a necessary link or make a page for that link. Then you change it to a real URL.

    Example:

    Say im making a site and I decide to make a tutorials section but I didn't make the page yet. Most webmasters would do this

    <a href="#">Tutorials</a> To show that there 'will be' a tutorials section, but it's not made or not up yet.

    Unless you want to jump to a certain area in a page then you would use <a href="#TOP">Back to Top</a>

    Would jump to where you set '#TOP' to.

    Hope that helps a lil.

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Also, the pound (#) can be used in place of an actual address, if the link's purpose is not to load a new page, but to call some javascript or something, as below:
    Code:
    <a href="#" onclick="window.open('popup_file.html', 'popup_name',
    config='height=xxx,width=xxx')">Click Here to open a popup window</a>
    With this code, the main page would not go anywhere, but a new popup window would open when you clicked the link.

    Dan

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Though it is good practice to put the link to the popup page there just incase the user has JS disabled by default (like me) then they would still see the link.
    Code:
    <a href="popup_file.html" onclick="window.open(this.href, 'popup_name','height=xxx,width=xxx');return false">Click Here to open a popup window</a>
    The key to that is to use return false after the window.open function. If you don't want to put the # in your href to create a dead link, you should be able to just leave it blank, though I think in IE this might open windows explorer (that could be only locally).

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Wow, thats cool! Thanks!

    Dan

  • #7
    New to the CF scene
    Join Date
    Nov 2005
    Location
    Washington State, US
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow !

    Thank you all for the excellent explainations and assistance.

    One thing that does still puzzle me though, is - if I use
    <a href="#"
    as a place holder, why doesn't that trigger an HTML code error ?
    thx

  • #8
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Because its not an error. You use a # to reference a name or id, if you just use the # the browser just loads the page looking for an anchor that refers to the # but since no name or id is set it just goes to the top of the page. Do you notice that the browser seems to reload the page if the # is pressed?

  • #9
    New to the CF scene
    Join Date
    Nov 2005
    Location
    Washington State, US
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ahhh... I understand now..
    Thank you all for the kind help.

  • #10
    Regular Coder harlequin2k5's Avatar
    Join Date
    Sep 2005
    Location
    Holiday, FL
    Posts
    635
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_
    Though it is good practice to put the link to the popup page there just incase the user has JS disabled by default (like me) then they would still see the link.
    I know I'm full of dumb questions, but please humor me...

    Why does one turn off javascript?

  • #11
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by harlequin2k5
    I know I'm full of dumb questions, but please humor me...

    Why does one turn off javascript?
    Adverts, popup windows, resizing the browser window, etc.

  • #12
    Regular Coder harlequin2k5's Avatar
    Join Date
    Sep 2005
    Location
    Holiday, FL
    Posts
    635
    Thanks
    18
    Thanked 0 Times in 0 Posts
    told ya it was a dumb question

    if one has their js turned off and a site has appropriate js (like a calendar or something like that) would that site then be lost to them or should the author have enough presence of mind to provide a non-js page?

    I myself do not use javascript - I don't know the language and I haven't really found anything appropriate for any of my sites (with the exception of a floating menu that I used more for novelty than practicality)

  • #13
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    It just disables a lot of annoying things on pages sometimes like marquees, ads, etc. I use the noscript FF extension, it disables JS on page by default, I have the option to allow the pages to use javascript temporarily or permanently. Authors should make sure their page is functional with JS disabled. JS should not be required for a page to work.

  • #14
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Quote Originally Posted by Error 404
    Adverts, popup windows, resizing the browser window, etc.
    Also… a lot of people tend to use other things to browse web pages besides the browser—I for one use my RSS reader to read most of my web sites nowadays—and those devices may not support javascript. The rule of thumb is, generally, if it's not a complete necessity, make sure it degrades gracefully. That goes for JS, Flash, CSS, etc. At least it should be a rule of thumb.

    My two cents…

  • #15
    Regular Coder harlequin2k5's Avatar
    Join Date
    Sep 2005
    Location
    Holiday, FL
    Posts
    635
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rmedek
    My two cents…
    That's worth a million to me

    Like I said - I don't use it because it's not really something I want to learn but I thought it was important for me to ask that question as a continually budding web designer

    Thanks for all the tidbits guys!


  •  

    Posting Permissions

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