There is a typo on line 4 of favorite_services.js that is causing inconsistencies.
if (window.sidebar || window.external.AddFavourite) { should be if (window.sidebar || window.external.AddFavorite) {
Also, I have been testing in Chrome and it is not displaying. The comments in this file say it should only display for FF/IE, any reason why Opera/Chrome/Safari have been neglected?
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | service_links-624364-6.x.patch | 2.68 KB | TheCrow |
| #17 | service_links-624364-6.x.patch | 192 bytes | TheCrow |
| #16 | service_links-624364.patch | 2.85 KB | TheCrow |
| #16 | service_links-624364-6.x.patch | 2.68 KB | TheCrow |
| #11 | service_links_favorites_multi_browser-624364-11.patch | 2.66 KB | andyf |
Comments
Comment #1
gbrussel commentedCorrection. That line should read:
if (window.sidebar || window.external) {This now works in IE 7, FF3 and Chrome. Haven't tested Opera/Safari/IE8/IE6.
Comment #2
Funkwarrior commentedNot working on Safari/Leopard
Comment #3
j. ayen green commentedThis error comes up on Mac with firebug (service links was breaking things on the Ubercart checkout page on a Mac in Safari, not FF, and turning it off fixed it)
service_links/js/favorite_services.js --> on line 4 TypeError: Result of expression 'window.external' [undefined] is not an object.
Comment #4
j. ayen green commentedI found the problem. The code on line 4 is testing for window.external.AddFavourite, but on Safari window.external is not an object, so you can't test for window.external.AddFavourite. You first need to test for window.external all by its lonesome. I've changed my code to the following and it works fine.
Comment #5
djflux commentedHere's the above code in a patch. In case people don't know how to patch, just cd to the js directory and run
patch -p0 < name_of_patch_hereThis fixed my Javascript and made it work on my site in Safari 4
Comment #6
TheCrow commentedAdded the support for Opera and Chrome, and Safari shouldn't have problems with it.
About Chrome it show just a message who ask to press CTRL + D, if someone has a better idea i'll be happy to integrate it.
No problem to support more browser but not alls allow the automatic bookmarking through javascript (this is the case of Chrome).
Comment #8
jbfelix commentedI had a syntax error with the patch.
This resolves the problem:
Replace:
if (window.sidebar || window.external.AddFavourite) {By:
if (window.sidebar || window.external || window.external.AddFavourite) {Comment #9
TheCrow commentedThanks Moove, reworked and pushed!
Comment #10
Peter Bex commentedI'm reopening this ticket because this is still broken in IE7 and 8. Firstly, the commit in 51a0f92c18df3eb6583d5c3cc6954c0cfaca19cd doesn't fix the "favourite" typo in the conditional (only in the actual call), which means that the expression
(window.sidebar || (window.external && window.external.AddFavourite))returns false (as theAddFavouriteproperty does not exist). This effectively causes the link to show up, but without Javascript functionality behind it (instead, it links to the same page again), because the outermost conditional succeeds but none of its sub-conditionals do. This is of course extremely confusing for the user.Furthermore, in IE7 and IE8 the bare expression
window.external.AddFavoriteraises an exception "object does not support this property or method", but actually calling the method does work nonetheless!I'm afraid the best check is just for the
window.externalproperty, and if it exists you'd have to assume that the method on it exists too.The attached patch (against 7.x-2.x) fixes this, and also simplifies the conditional tree, so that it will always finish hiding the link when no supported method is found.
Comment #11
andyf commentedI'm not sure I get the logic of popping up an alert for some browsers, but hiding the link for others. IMHO it would be nicer to just use an alert() whenever there are problems doing things automatically. Or have I missed something?! I've attached a patch based on #10.
Thanks
Comment #12
Peter Bex commentedYeah I agree that's confusing. It's probably better to always hide the link on browsers where it's not supported.
Comment #13
simon georges commentedJust closed #1903234: Favorites service link doesn't work in Internet explorer as a duplicate of this one.
Comment #14
simon georges commentedCould someone re-roll the patch? It doesn't apply on current -dev.
Comment #15
TheCrow commentedThis have to be rewrite after the last patch provided by TimeRider, let me try!
Comment #16
TheCrow commentedpatch updated i used #11 but credits go to Peter Bex and AndyF
Comment #17
TheCrow commented[Error to send] go below
Comment #18
TheCrow commentedforgot 2 ;
Comment #19
TheCrow commentedCommitted for both branches!