SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2000
    Location
    England, UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question AJAX - Change URL?

    Hi,

    I had an application that worked on a principle of _get where each ?id in the URL loaded different data.

    I've moved to ajax and it works fine, just the text area of the page changes and it works fast (albeit without a working back button at present). But part of the idea with using _get was so that people can link to specific sections of the page.

    The get option still works, people can do /page.php?5 and get the information on ID 5 but as soon as you start using it again the url changes to /page.php# of course. Is there any way to change this so that you get the ?id appearing in the URL without going back to a "re-load entire page every time" option?

    I had a quick search here and at google but couldn't see anything related, although I'm sure I read about it, somewhere?

    Thanks!
    You think you know nothing? You haven't met me yet :-)

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jc94062
    as you start using it again the url changes to /page.php# of course
    This is not an "of course" thing! This is a design decision, and having your links point to "#" is just poor design. Does this whole thing fall apart if someone doesn't have the latest-greatest browser with XMLHttpRequest support and JavaScript enabled too?

  3. #3
    SitePoint Member
    Join Date
    Jun 2000
    Location
    England, UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thats helpful

    It checks for activeX stuff in that fails and goes to standard get usage if they have javascript disabled.

    Of course seeing as the site requires javascript to login (that decision was made well over me) I don't see that as a major issue anyway.

    As far as I was aware your links had to point to # if you were using onClick type commands.
    You think you know nothing? You haven't met me yet :-)

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jc94062
    As far as I was aware your links had to point to # if you were using onClick type commands.
    There's no such requirement... they can point to real URLs for people with JavaScript disabled, but as you're requiring JavaScript anyway, there's no point in discussing this further.

  5. #5
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The use of the octothorpe (#) as the target of a link with an onclick handler is just a safety; it basically makes the link valid without it actually pointing to anything.

    As Mr. Grossman points out, a valid URL can exist as the href attribute, regardless of an onclick handler. If the onclick code concludes with 'return false' the link will not be activated if the JavaScript is executed; otherwise the link will be activated when the script concludes. This allows a different outcome if JavaScript is enabled than if it is not.

    It might be worth looking into using the noscript element; it would allow you to inform those without JavaScript enabled of its necessity for proper function.

  6. #6
    SitePoint Member
    Join Date
    Jun 2000
    Location
    England, UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks guys!

    Some helpful hints there, thanks.
    You think you know nothing? You haven't met me yet :-)


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
  •