I use CSS3PIE to render my css in IE (rounded corners, drop shadows, etc...), but it turns out that links which call "javascript:void(0)" break that script. So now, if a user on IE clicks to advance my jcarousel slides, my drop-down menus go all wonky and loose their formatting on hover.

Apparently href javascript links fire the onbeforeunload event, even though the page is not unloaded. I expect CSS3PIE is not the only script that might suffer from this problem.

Would it be possible to remove javascript:void(0) from the links and use a different method to prevent the link from triggering a page load? For instance, I noticed that Views Slideshow doesn't use javascript:void(0) in its links.

Comments

quicksketch’s picture

Priority: Normal » Minor

I'd really strongly recommend you file an issue with that library, as javascript:void(0) is extremely common JavaScript, even today. I would consider this a bug in their code more than jCarousel, but you're right that we could adjust our code to use href="#" instead, and then suppress the default browser behavior with JavaScript code elsewhere.

jstoller’s picture

The issue has already been reported to CSS3PIE and I believe it has been fixed (at least in their dev version). However, I get the feeling that they may not be the only script that could be impacted by this issue. As I understand it, using jQuery's preventDefault() function is a more appropriate solution anyway, so perhaps it's still worth updating jCarousel to use that approach and we can all sleep better at night.

quicksketch’s picture

As I understand it, using jQuery's preventDefault() function is a more appropriate solution anyway

Yes, probably "more appropriate", but at least 3 lines of code instead of a nice short string. Backwards-compatible code is one of the cornerstones of the HTML5 movement, so it's a little unfortunate that newer libraries are incompatible with common JavaScript conventions.

quicksketch’s picture

Status: Active » Closed (won't fix)

Well after seeking other opinions, I don't think that we should change our approach here. While using # as the anchor href is also very common, it presents some downsides that gives javascript:void(0) an advantage. See:

http://stackoverflow.com/questions/134845/href-for-javascript-links-or-j...

We'll let CSS3PIE fix this on their end, if they haven't already.