unrecognized Expression: a[href=#! ]

Asked

Viewed 328 times

-1

In the URL, if I leave only dominio.com.br the site works normally if I put dominio.com.br/# still working too, but when putting dominio.com.br/#! the site returns me this error

Uncaught Error: Syntax error, unrecognized Expression: a[href=#!]

in the jQuery file (1.9.0).

  • 3

    You can put an example of code?

  • Have you tried with another version of jQuery? A newer version?

  • You’ve seen it working somewhere?

  • You’re taking the url and going to some function or something?

  • 2

    In my opinion, it would be correct to give an error like this, because right after # usually try to access a place inside the html that contains the id... ex: are.html?#id-3434 then arrow the screen to the height of that place for example a div with id="id-3434" and in that case the problem is that ! is not valid for an id

  • I’ve tried with several versions of IE, from 1.8.2 to 1.11.0.

  • 1

    It can be a plugin that manages browsing history. Could you provide more details, what plugins and/or frameworks js you are using, if your own code tries to do something with the URL, etc? The way it is, you can’t answer your question, and it would need to be closed.

Show 2 more comments

1 answer

0

jQuery is trying to use the final portion of the URL as ID in a query, but there is no element with that ID ("!") on the page, so jQuery launches the error. You have to make sure that the element EXISTS in the body of the page, and that it has a valid ID, which can be referenced in the URL.

  • It’s true, I also think that’s what’s happening. But jQuery doesn’t do it alone. Either you have a plugin trying to use part of the hash as ID, or it’s code that the author himself wrote. But it is not possible to say which of these two is the case, because the author did not provide enough information.

  • 1

    I fully agree. I was going to guess that it was some smooth scrolling plugin, but then I read that it was not to respond on the basis of "I think"... haha!

  • 1

    Actually it was not I who developed the jquery code, I got this code ready, and it is being used several plugins, I’m also in the "achometer" which is some plugin, but I can’t identify what it is, I’ll keep looking, if I find I put here. thank you all.

  • @Rodrigogalter Good to have a feedback from you, I thought you had abandoned the question. Look, as it is, it is quite capable that it be closed even. But if you later edit it with more information (even closed), it can be reopened. If you need help with this in the future, look me up here on the site.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.