Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error msg with IE9 #92

Closed
thejaas opened this issue Sep 1, 2011 · 17 comments
Closed

Error msg with IE9 #92

thejaas opened this issue Sep 1, 2011 · 17 comments

Comments

@thejaas
Copy link

thejaas commented Sep 1, 2011

Hi,

I get this error message with IE9 (probably because it's html4): History.js does not support states with fragement-identifiers (hashes/anchors)

What does this error msg mean? In which cases it pops? Any ideas of how can it be fixed?

@thejaas
Copy link
Author

thejaas commented Sep 3, 2011

bump, :) anyone?

@dekaru
Copy link

dekaru commented Sep 19, 2011

I'm having the same issue on Internet Explorer 9 with the latest release :(

The URL I'm loading is

http://localhost/index.php/#./?&_suid=142

Upon initial load, I fire a History.replaceState with my new state and an empty title and url

The console output is:

SCRIPT5022: History.js does not support states with fragement-identifiers (hashes/anchors).
history.html4.js, line 1 character 2843

If I set State.url to something, it doesn't happen anymore, but my URL gets appended whatever I set in the State, which is even more cumbersome.

balupton added a commit that referenced this issue Oct 4, 2011
@balupton
Copy link
Member

balupton commented Oct 4, 2011

Can you confirm this is fixed in v1.7.1?

@balupton balupton closed this as completed Oct 4, 2011
@jokeyrhyme
Copy link

I am still getting this error message in IE9 with 1.7.1-r2.

When I first load my site, I do not get any error messages. I have History.replaceState(null, null, '/demos/'); call in my web application, which changes the URL to http://localhost/demos#/demos/

If I now hit Refresh, then I see no error message. The URL is now:
http://localhost/demos#/demos/&_suid=1318214386420011513650802855002

If I now hit Refresh again, then I see the error message again.

I tried detecting the # in the URL and using location.assign() to remove it, but I ended up in an infinite loop. I guess loading the History JS library in the first place is what adds it in. I tried putting a try/catch around the replaceState line, but saw no change, so I don't think using replaceState is the cause.

@philwhln
Copy link

I'm seeing this error too with the latest version from github.

@jokeyrhyme
Copy link

I ended up duck-punching pushState and replaceState so that they cull fragment identifiers (the hash and everything after it) from states before doing what they normally do. This seems to be working well enough for me, but I'd really rather not have to do something so cheesy. :P

My project will eventually move to jQuery Mobile, so I expect I'll have to deal with whatever issues their implementation of HTML5 History introduces too. Or do they use this library too?

@philwhln
Copy link

I tracked my issues down to the fact that I was passing "" as the state url for the root page. This turns into "./" inside History.js which causes all sorts of issues. Using "/" doesn't cause these problems, although I am actually using some form of "?state=1", as in the examples.

Ron, I noticed that you are not starting your state urls with "?". Maybe this is causing your problems. History.js tries to make the URL relative (hence "" becomes "./") and so starting with "/" might be causing your problems. Although, my understanding of this is still shakey.

@jokeyrhyme
Copy link

It merits further investigation. However, all of the URLs that I pass into History.JS already have slashes in them. I would hope that History.JS sees sufficient slashing and doesn't attempt any further mangling.

I would consider it a bug if the presence of a question-mark (?) was either mandatory or not allowed. ?s are to help the server parse a request, the only thing a browser should care about is the hash (#) an what comes before and after it.

@joakimjohansson
Copy link

I recently bumped into this issue, my urls look something like this: http://site.com/view.aspx?Id=365 and I was using pushState({ obj }, null, null); which works fine in "html5-mode".

In html4 it modified the url to behttp://site.com/view.aspx?Id=365#view.aspx?Id=365&_suid=12345678901234567.

After I changed to using pushState({ obj }, null, "/"); the urls are now: http://site.com/view.aspx?Id=365#/?&_suid=12345678901234567 and work fine in html4 browsers.

@mattburns
Copy link

I faced this problem and just migrated to using this plugin instead which solved my IE9 problems:
https://github.com/devote/HTML5-History-API

@pjfarsi
Copy link

pjfarsi commented Jul 31, 2013

I was getting this error on a simple test

History.pushState({ step: 0, id: "AutosWidget" }, document.title, document.URL);

The error was gone when I changed document.URL to "?"

History.pushState({ step: 0, id: "AutosWidget" }, document.title, "?");

@DilipRajkumar
Copy link

I also had the issue then I did the following and now I did not get the issue

History.replaceState(null, null, '/web/search.html');

History.replaceState(null, null, '?q='+searchTerm);

@bbuchalter
Copy link

@balupton this issue is still happening on master for jquery and native bundled uncompressed versions. I'm invoking as such:
window.History.replaceState(null, document.title, href)

The href variable in this case is being interpreted as follows, but should be interpreted (and is by modern browsers) in the following format http://localhost:3000/products/360-sport-square-cut-brief?size=M&color=72
screen shot 2014-10-28 at 8 36 18 am

And here are the exceptions raised in IE9 for jquery and native versions:
screen shot 2014-10-28 at 8 35 43 am
screen shot 2014-10-28 at 8 34 17 am

@bbuchalter
Copy link

I can also confirm that on master, @DilipRajkumar's suggestion does not seem to fix the issue any longer.

@bbuchalter
Copy link

It also seems @pjfarsi's strategy does not work any more either, although I am using replaceState and he's using pushState.

@bbuchalter
Copy link

It seems I was mistaken. @DilipRajkumar's solution does still work. No exceptions raised in IE9. I was just expecting the URL to look different, but I had forgotten this was a "HTML4" friendly URL. So the final question here really is that do we need to draw attention to this in a README perhaps?

@bbuchalter
Copy link

One more note to this, the following solution has a side effect:
URLs in HTML5 browsers get an extra slash added before the ? delimiter, so this URL:
http://localhost:3000/products/second-skin-boxer-brief
becomes:
http://localhost:3000/products/second-skin-boxer-brief/?size=M&color=1

Not sure if this a show stopper, but it does seem unconventional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants