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

check browser after checking for hashchange #47

Closed
wants to merge 1 commit into from
Closed

check browser after checking for hashchange #47

wants to merge 1 commit into from

Conversation

manbearwiz
Copy link

jQuery 1.9 removed support for $.browser in favor of solutions like Modernizr. This produces the following error in Chrome

Uncaught TypeError: Cannot read property 'msie' of undefined

While moving to Modernizr would make sense, this simple fix is enough for most that run into this. In my case I do not need support for Internet Explorer 6, 7, or 8 so I am using jQuery 2 which removed that support. Because I am only supporting browsers which support the hashchange event, moving the call to $.browser means it is never executed due to short-circuit evaluation.

jQuery 1.9 [removed support for `$.browser`](http://api.jquery.com/jquery.browser/) in favor of solutions like [Modernizr](https://modernizr.com/docs/). While moving to Modernizr would make sense, this simple fix is enough for most that run into this. In my case I do not need support for Internet Explorer 6, 7, or 8 so I am using jQuery 2 which removed that support. Because I am only supporting browsers which support the `hashchange` event, moving the call to `$.browser` means it is never executed due to short-circuit evaluation.
@Krinkle
Copy link

Krinkle commented Sep 14, 2015

This doesn't seem like an appropriate solution.

See also issue #42 (and its many duplicates).

Duplicate of pull-request #40, #45, and two dozen duplicates at https://github.com/cowboy/jquery-hashchange/pulls trying to solve the same problem.

@manbearwiz
Copy link
Author

Yah my mistake. I should have looked at the open PRs before I made this. Turns out this dependecy wasn't really needed by our project anymore as we could just replace:

$(window).hashchange(_hashChange);

With:

window.addEventListener("hashchange", _hashChange);

@manbearwiz manbearwiz closed this Oct 19, 2015
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

Successfully merging this pull request may close these issues.

2 participants