views:

402

answers:

2

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

+3  A: 

looks like you copied directly from the example at the plugin's website. your address.change function does nothing, there are only two commented lines in there.

Brandon H
So there website should have the address.change on it somewhere? In the source of their demos? I thought that was a jQuery function.
S.Kiers
my mistake. maybe that function takes in a callback function? i'm relatively new at all this? all i know is i saw a function that doesn't do anything.
Brandon H
A: 

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?

S.Kiers