Jump to content

Appending a dynamic URL with # anchor without adding pages to history


Riddler

Recommended Posts

Hi there!

I've been searching for days across loads of forums to try and find an answer to this. I've read some posts that seem to get near a solution but they aren't quite what I need.

 

I have installed a neat little piece of code on my site called codaslider http://www.ndoherty.biz/tag/coda-slider/.  I originally had problems with navigating around the tabs as every link sent the page back to the root;

instead of mysite.com/page.php?thispage_id=42#anchor2

it would navigate to mysite.com/#anchor2

 

I got around this by adding +location.href+ into the link i.e;

ul.append('<li class="tab' + (n+1) + '"><a href="'+location.href+'#' + (n+1) + '">' + $(this).find(settings.panelTitleSelector).text() + '</a></li>');

 

Navigation works and the tabs move about now BUT it adds a new page to the browser's history every time a new #anchor is clicked. I would like the #anchors to be clickable without adding another page to the browser's history.

 

Is this possible?

 

All help is greatly appreciated!

Tim.  ;D

Link to comment
Share on other sites

I've read some info at http://www.w3schools.com/jquery/jquery_ref_html.asp and suspect I need to change something to do with ul.append but just cannot get the code to work as I want!

 

I'm guessing it took you 30 seconds because you knew what to look for, I've got very little idea what I'm doing.  :shy:

 

Allow me to reiterate; help is greatly appreciated.

Tim.

Link to comment
Share on other sites

Unbelievable. After days (the total of which must be some ridiculous number of hours) it turns out the solution was under my nose.

 

I'm still not entirely sure how setting crossLinking:false works to prevent a history trail being created every time you click a tab. For the purposes of future reference I'd like to know this works, so I'll forage around the code a little, but for the moment I'm very happy!  :D

 

Thank-you thorpe for the pointer, I really appreciate your efforts to point out this ultra simple (as it turns out) fix!

 

Cheers, Tim.  ;)

 

 

Link to comment
Share on other sites

I haven't looked at the code, but it probably adds the hash to allow for deeplinking (i.e. bookmarking a specific selection in the slider) which can also be good for SEO. It's probably on for default, but they appear to give you an option to turn it off.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.