Fixing jQuery and Java Applets

I’ve been pretty quiet recently. Not a lot has happened except I’ve been working a fair bit recently, along with trying to pull myself out of various bits of mess I landed myself back at the end of spring. Today I’ve run into a nasty bug with jQuery and Java Applets.

The Bug

Due to the nature of jQuery it appears that it likes to transverse through the DOM and do various alterations to it. This is all fine, until it comes to a pesky Java Applet. Java Applets however modify the behaviour of the host EMBED/OBJECT tag, probably because the Applet’s public methods are exposed as an external interface so that the applet can be controlled by JavaScript.

currently there is a bug open for this on the dev site

The Fix

My way round this was to block jQuery from attempting to attach events to the JavaApplet. The implementation is a little dirty (see link above about issues with OBJECT being used in XHTML 2.x to replace IMG tags).

Place this below ‘nodeName’ function

isExternal: function(elem) {
    return (jQuery.nodeName(elem, 'embed') || jQuery.nodeName(elem, 'object') || jQuery.nodeName(elem, 'applet'));
  isHtmlElement: function(elem) {
    return !(elem.nodeType == 3 || elem.nodeType == 8 || jQuery.isExternal(elem));

Replace …

@elem.nodeType == 3 || elem.nodeType == 8

… with …


… throughout the rest of the jquery.js file.

Hopefully this will save a few other people going through the torture I had to go through, particularly as Internet Explorer also throw up some rather vague errors in the process of testing.

Listening to Ambient Rock / Experimental:
East Hastings - Godspeed You Black Emperor!

Free Designs

Below are a handful of open source / free web designs