history.js icon indicating copy to clipboard operation
history.js copied to clipboard

Not able to use # in url links.

Open buldozer911 opened this issue 12 years ago • 7 comments

When i try to push following state, arguments are not getting pushed in history. History.pushState({ state: reqId, args: arguments }, null, "#" + reqId);

However, if i use "?" in place of "#" it is working properly..

buldozer911 avatar Jan 30 '13 11:01 buldozer911

I think that's a desired behavior, I think a exception is thrown also when you use a # in url. History.js supports HTML4+5 browsers and for HTML4 browsers hashtags are used to map url.

ghost avatar Jan 30 '13 11:01 ghost

Currently our system uses # in urls and for some reasons we want to keep it that way.. Could you please tell if there is any workaround..

buldozer911 avatar Jan 30 '13 11:01 buldozer911

You can activate html4Mode (only in unofficial 1.8a2 version of this fork: https://github.com/andreasbernhard/history.js#options). Then you keep hashes with # in url. But please don't put # chars in url, because History.js adds them automatically. A url like: test.com/#test#test isn't valid!

ghost avatar Jan 30 '13 11:01 ghost

Thanks for responding so quickly! Let me try that..

buldozer911 avatar Jan 30 '13 11:01 buldozer911

I downloaded the above mentioned fork and activated html4mode. I pushed the following state from one of the buttons. History.pushState({state:1,rand:Math.random()}, "State 1", "state=1");

URL changed to http://localhost:1528/history18/demo/index.html#./state=1?&_suid=1359611275677017746907970120118

i don't need extra "./" it should like

http://localhost:1528/history18/demo/index.html#state=1?&_suid=1359611275677017746907970120118

buldozer911 avatar Jan 31 '13 05:01 buldozer911

So it worked but there is a basepath issue, so ./ is appended. I entered it as a issue.

ghost avatar Jan 31 '13 11:01 ghost

Trying to accomplish this using your fork but it doesn't seem to work. which package should I be using

karneaud avatar Nov 08 '14 15:11 karneaud