gfranko / jquery.tocify.js

A jQuery Table of Contents plugin that can be themed with Twitter Bootstrap or jQueryUI.
http://gregfranko.com/jquery.tocify.js/
MIT License
927 stars 217 forks source link

generateHashValue not Chrome and Firefox friendly when elements have "?" or other special characters in them #28

Closed shrisha closed 11 years ago

shrisha commented 11 years ago

For e.g., an element named "Is this a question?" generates a hash value of "#Isthisaquestion?". however, when window.locaiton.hash is set to this value, Chrome, Firefox, and Safari seem to be dropping the hash thereby mangling the URL. The fix (which I'm hoping to push and request a PR is to strip out all non-alpha-numeric from the element in the generateHashValue function.

matryer commented 11 years ago

I'll fix this later

On 12 Apr 2013, at 16:48, Shrisha Radhakrishna notifications@github.com wrote:

For e.g., an element named "Is this a question?" generates a hash value of "#Isthisaquestion?". however, when window.locaiton.hash is set to this value, Chrome, Firefox, and Safari seem to be dropping the hash thereby mangling the URL. The fix (which I'm hoping to push and request a PR is to strip out all non-alpha-numeric from the element in the generateHashValue function.

— Reply to this email directly or view it on GitHub.

shrisha commented 11 years ago

I just sent you a pull request.  See if that makes sense.  Works here against all browsers.

Cheers, Shrisha — Sent from Mailbox for iPhone

On Fri, Apr 12, 2013 at 4:12 PM, matryer notifications@github.com wrote:

I'll fix this later On 12 Apr 2013, at 16:48, Shrisha Radhakrishna notifications@github.com wrote:

For e.g., an element named "Is this a question?" generates a hash value of "#Isthisaquestion?". however, when window.locaiton.hash is set to this value, Chrome, Firefox, and Safari seem to be dropping the hash thereby mangling the URL. The fix (which I'm hoping to push and request a PR is to strip out all non-alpha-numeric from the element in the generateHashValue function.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub: https://github.com/gfranko/jquery.tocify.js/issues/28#issuecomment-16322295

gfranko commented 11 years ago

@shrisha I don't see Chrome or Firefox dropping the hash from the URL if the hash contains a special character. Do you have an example page I could look at?

shrisha commented 11 years ago

@gfranko You're correct! I could have sworn my standalone simple HTML file using tocify also exhibited this behavior; but, in fact doesn't. however, the site we're working on has this problem and I'm guessing it's do with either require.js or bootstrap. i'll try to get an example HTML file showing the issue. The fix I made locally does fix the issue for us, at least. but, I'm not sure who's causing issue.

gfranko commented 11 years ago

Okay, I'm going to close this issue for now, but if you can show that it is a Tocify bug then I will reopen it.