Search code examples
javascriptjqueryajaxjquery-pluginsbookmarks

Using Bookmarks with jQuery Address


I am using jQuery's Address plugin (website) to enable the back/forward buttons on my website. I would REALLY like to also have the ability for people to bookmark pages and to copy the address from the address bar and share it with friends. Address claims it can do this, so then what am I doing wrong.

My code is

function BackButton() {
 $.address.change(function(event) {
  // do something depending on the event.value property, e.g.
  // $('#content').load(event.value + '.xml');
 });
 $('a').click(function() {
   $.address.value($(this).attr('href').replace(/^#/, ''));
 });
}

BackButton() is then called on every AJAX pageload to ensure it works with the pages loaded by ajax.

Thanks for your help


Solution

  • So I used

    if ( $.address.value() !== "\/" ) {
        window.location = "http://www.domainname.com/" + $.address.value()
    }
    

    to redirect the user to the correct page.

    So is this correct? Or are their problems with it?
    What would be the benefits of using the $.address.init function of jQuery.Address?

    Also this forces them to wait until the page (&javascript) is loaded to see any content. comments?