SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast nelovishk's Avatar
    Join Date
    Dec 2004
    Location
    Guadalajara, México
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Linking to a non-existent named anchor

    I'm trying to use bookmarked anchors (ie. URL#anchor) to store data in a similar way you would use GET form data, but I don't want to put all the <a> named anchor tags in the document.

    What problems can I get into if I link to nonexistent named anchors?

    What I want to do is to be able to restore the location of a user in a page that will contain a large amount of DHTML navigation. I want to know, when a user opens the document, exactly what content was he or she viewing within that page (what divs were turned on, basically). Therefore, I could have something like:

    http://www.somesite.org/page.html#1-1&2-1&3-0

    That would tell me (after parsing the string as if it were GET data) to turn on DIVs 1 and 2, but not three... something like that.

    I hope everything is clear, let me know what you think
    See any mistakes? Please tell me! I need to improve my English.

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a misuse of named anchors. Why not just use the get/query string?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Enthusiast nelovishk's Avatar
    Join Date
    Dec 2004
    Location
    Guadalajara, México
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because that would imply reloading the document and sending data to the server. I want everything to be client-side, and I want the visitor to be able to bookmark a specific part of it.

    I want to do what you can't do with gmail, for example. If you bookmark gmail, it always points to your inbox, not to the message you were reading...

    I'm sure it's a misuse of named anchors, but I can't think of another way...
    See any mistakes? Please tell me! I need to improve my English.

  4. #4
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might also run into accessibility and usabitily issues, too.
    I will not flame the newbies,
    I will not flame the newbies,
    I will flame the newbies...
    Table free is the way to be!

  5. #5
    SitePoint Enthusiast nelovishk's Avatar
    Join Date
    Dec 2004
    Location
    Guadalajara, México
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, specially accesibility issues.. because the navigation and the structure of the document could end up being very odd. That's not my primary concern by now, though, because of the kind of site I'm developing.

    I'd like to focus on the technical side of things... is it possible to do that in an efficient manner? (store data as named anchors and retrieve with javascript)
    See any mistakes? Please tell me! I need to improve my English.

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another problem is that it will not fail gracefully, since it requires a lot of JavaScript.

    You can use the location.href to retrieve the fake named anchor.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  7. #7
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    UK, London
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use location.href.hash to get the anchor name.

    Storing data in an anchor name is as evil as badly developed ASP.NET's way of storing a very long session data string in a hidden form field.

    The technical feasibility is really not the problem here, it simply is a bad idea and will end in a bad example that inexperienced developers will love and imitate.

    If you use AJAX, as GMAIL does, you might as well offer a bookmark link that generates a unique ID as a hash to talk to the backend.

    The fact is that you make the browser do things it was not supposed to and still expect it to behave like nothing happened. It is the same issue with Flash only sites and Macromedia's horrible workaround of a hidden IFRAME to allow bookmarking.
    Chris Heilmann
    Blog | Articles | Binaries

  8. #8
    SitePoint Enthusiast nelovishk's Avatar
    Join Date
    Dec 2004
    Location
    Guadalajara, México
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm I'm still doubtful.

    Quote Originally Posted by Kravvitz
    Another problem is that it will not fail gracefully, since it requires a lot of JavaScript.
    That's a good point... since the navigation would require JavaScript and there's no way to avoid it in this case, AFAIK

    I'm aware that I'm doing the kind of development we all hate to maintain. I'm also aware that what I'm proposing here is not standard and definitely the least elegant way of implementing a site's navigation, but for this case, it would be really useful.

    Quote Originally Posted by codepoet
    The technical feasibility is really not the problem here, it simply is a bad idea and will end in a bad example that inexperienced developers will love and imitate.
    Yup... the kind of "exciting" development that ends up being a nightmare to maintain... But if it's technically feasible (in a cross-browser manner, of course), I might be willing to get into it...perhaps I'm just being blind...

    Thanks for your answers, keep the comments comming =)
    Last edited by nelovishk; May 26, 2005 at 16:59. Reason: stupid finger made mistake
    See any mistakes? Please tell me! I need to improve my English.

  9. #9
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codepoet
    You can use location.href.hash to get the anchor name.
    You mean location.hash, which contains only the part after the '#' in location.href and would be easier to use for this.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  10. #10
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    UK, London
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nelovishk
    Yup... the kind of "exciting" development that ends up being a nightmare to maintain... But if it's technically feasible (in a cross-browser manner, of course), I might be willing to get into it...perhaps I'm just being blind...
    If you were blind, chances are you wouldn't be able to use your product, and the issue would solve itself. Screen readers only render dynamic content to a certain level :-)
    Chris Heilmann
    Blog | Articles | Binaries


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
  •