jquery-hashchange icon indicating copy to clipboard operation
jquery-hashchange copied to clipboard

Removed $.browser

Open gseguin opened this issue 13 years ago • 14 comments

gseguin avatar Oct 15 '12 20:10 gseguin

Are you going to fix it? jQuery 1.9 is here.

jazzfog avatar Jan 17 '13 23:01 jazzfog

+1

pehrlich avatar Jan 31 '13 21:01 pehrlich

Hi,

We have updated our site with jQuery 1.9 and the hashchange plugin is the only one not working! It triggers an error, please see here: https://github.com/cowboy/jquery-hashchange/issues/25

Please is there a quick fix, I was thinking of an alternative to detect IE?

We've removed the hashchange plugin altogether for now and are actively looking at an alternative or a fix... Our entire site now suffers from missing back button support, what a shame :( Thanks for any help!

ghost avatar Feb 01 '13 14:02 ghost

@anonumus As per the upgrade guide, use this: https://github.com/jquery/jquery-migrate/

pehrlich avatar Feb 01 '13 16:02 pehrlich

a quick and dirty fix would be to replace the one instance of ...

$.browser.msie

with

/msie/.test(navigator.userAgent.toLowerCase())

... this is by no means full proof

JohnCz avatar Feb 02 '13 19:02 JohnCz

My Solution is

Open source plugin source code and replace

$.browser.msie

with

(navigator.appName == 'Microsoft Internet Explorer')

jazzfog avatar Feb 03 '13 00:02 jazzfog

Better solution :)

(navigator.appName === 'Microsoft Internet Explorer')

fdaugan avatar Feb 09 '13 19:02 fdaugan

Is there any difference in this particular case? ;-)

jazzfog avatar Feb 09 '13 19:02 jazzfog

Thanks all for the quick fixes ;) Using jQuery Migrate isn't an option... we want to move forward, not backward, we have 10 others libs/plugins that work great with jQuery 1.9, this one is the oldest one without an update in 2 years.. and is the only one that triggers an error!

By the way, I'm surprised that there is no other option than this outdated plugin for an "hashchange event" in jquery, considering the popularity of sites using ajax that use URLs like /#!pageID (i.e. twitter & co...) Am I missing something? or is there another way to detect the "hashchange" event in jQuery? or is this really THE ONLY plugin that exists for this????

ghost avatar Feb 10 '13 19:02 ghost

You can use "routie" : no JQuery dependency, but works only for IE8+ and modern browsers. I was used to use routie before I had to support IE7.

fdaugan avatar Feb 10 '13 20:02 fdaugan

@fabdouglas Did you already to look at https://github.com/andreasbernhard/history.js ?

pthorson avatar Feb 17 '13 06:02 pthorson

History.js does not handle direct links such as :

<a href="www.mysite.com/#?state=1&_suid=1">Display</a>

It manipulates history, so covers another web feature. (personnaly) I use jquery-hashchange to listen this internal navigation requests to load some content. This way I cover bookmarks, back, forward, etc.

fdaugan avatar Feb 17 '13 11:02 fdaugan

I just discovered History.js and it looks really nice!! I'm seriously considering using it! However the main concern is its huge weight, come on 20KB+ minified for one simple feature... As a comparison, jquery.ba-haschange is 2KB only... I'd rather keep with it and implement the HTML5 history stuff myself...

ghost avatar Feb 17 '13 19:02 ghost

We have removed the browser sniffing condition: the plugin already checks, in a better way, if browser supports the hashchange event:
supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );

So we changed this line: $.browser.msie && !supports_onhashchange && (function(){ in: !supports_onhashchange && (function(){

danbalbo avatar Mar 06 '13 10:03 danbalbo

Another way to fix this bug http://stackoverflow.com/questions/14512826/impromptu-with-jquery-1-9-error-with-browser-msie

Tested with Jquery 1.9.1

sylvainlg avatar Mar 18 '13 09:03 sylvainlg

Change line 300

From:

$.browser.msie && !supports_onhashchange && (function(){

To:

/MSIE/.test(navigator.userAgent) && !supports_onhashchange && (function(){

That's all jQuery.browser does anyways.

Description: Contains flags for the useragent, read from navigator.userAgent. We recommend against using this property; please try to use feature detection instead (see jQuery.support). jQuery.browser may be moved to a plugin in a future release of jQuery.

http://api.jquery.com/jQuery.browser/

andey avatar Apr 09 '13 23:04 andey

I kind of prefer not to modify plugins directly... If you do something along these lines before you include hashchange plugin that would work as well...

$.browser = {msie: (navigator.appName === "Microsoft Internet Explorer")};

not tested in IE, just thought of it from the comments above- this is assuming the fact that navigator.appName is a safe way to test for IE (yes, we know nothing is a safe way to test)

rkingon avatar Jul 03 '13 17:07 rkingon