So I sat down and decided to work on my image script some more. I decided it was high time to add the keyboard commands, so I did that. I went through and tested in other browsers. Everything's fine, but when I press Spacebar to open the image list in Opera...
Opera mysteriously navigates to the next image.
What the hell? I went into my code and made absofuckinglutely sure that there was no possible way that next() could be called erroneously. It does appear in my keyboard handler's switch statement after the code for the spacebar, but not only did I properly slap a break; up in there, the code for the previous image is between that of the image list and the next image, with its own break;.
At this point I toss a couple alert()s around just so I can see what's happening. Put one in the keyboard handler just before the call to next(), save, refresh the page, press the spacebar, and no alert box. Moved it to the first line of next(),saved, refreshed the page, pressed the spacebar, and wham, an alert box. The image in the background hadn't changed yet, and the image list also hadn't been shown yet. Click OK, then the image changes and the image list shows up.
So essentially, Opera is phantomly calling my function.
I play around with it some more. Renamed the existing next() to derp(). Made next() a wrapper that shows an alert box and then calls derp(). Edited my keyboard handler to call derp() in place of next(). Saved and refreshed the page, pressed the spacebar, and no alert box.
So at this point I think it's something really weird with the event handler. Also at this point I devise a workaround. Test to see if the dialog is displayed, and return from next() if it is. Renamed stuff back to what it should be, deleted the wrapper, saved, refreshed, and no more phantom navigation.
I was happy that I bitchslapped Opera into working like all the other browsers do, but I was still wondering why it was calling next(). On a hunch, I renamed the function, commented out the workaround, and changed the function calls in the links to use the new function name. Save, refresh, and... the image changes.
So, basically, Opera erroneously acts as if the "Next" link has focus. Which is weird because when I click any other link (like, "Previous") and then hit spacebar, it still goes to the next image. It's also doubly weird because internet browsers for some lame-brained idiotic fucktarded reason bind Spacebar to Page Down, and Enter selects links. If I want to hit Page Down, I'm going to fucking hit Page Down. That still doesn't explain why it tries to navigate the "Next" link when I press the spacebar.
Is there a similar phantom function call I should know about for my "Previous" link?
Why do 90% of my browser-specific workarounds have to be for Opera, to bring it in line with all other browsers?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
I moderate comments because when Blogger originally implemented a spam filter it wouldn't work without comment moderation enabled. So if your comment doesn't show up right away, that would be why.