Bug Tracker

Opened 15 years ago

Closed 14 years ago

#2349 closed bug (fixed)

Script error leaving page with applet tag (related to #1675?)

Reported by: JesperSJensen Owned by: flesler
Priority: major Milestone: 1.4
Component: data Version: 1.4a1
Keywords: Cc:
Blocked by: Blocking:


A new ticket created! Also in comment to #1675!

Applet tag (and script) on html gives script error

I have problem in firefox version 'xx.xxx.xxxx.class has no public field or method named "JQuery....' Error introduced AFTER 1.2.1! Problem introduced in 1.2.2 (and still in 1.2.3).

No problem in ie7.0.

My html produce a valid html document with a applet tag. And everything works fine with jquery 1.2.1. Error is when leaving page (cleanup cache?) My html:

... <div class="applet">

<script type="text/javascript">



<script type="text/javascript">




In jquery 1.2.3 (developer version) error is in line 674 (it seems to be when cleaning cache for elem = script!).

Compute a unique ID for the element

673 if ( !id )

674 id = elem[ expando ] = ++uuid;




Change History (12)

comment:1 Changed 15 years ago by DanSwitzer2

I'm seeing this exact same issue, but I also get an error as soon as you try to hide an applet as well. I've set up an example at:


On the first page load, it'll work correctly. When you reload you'll get an error.

comment:2 Changed 15 years ago by DanSwitzer2

After some more research, this appears to be related to problems with applet and object tags (which contain Java applets) when trying to write expando properties in Firefox v2.x.

If I change the data() method to:

data: function( elem, name, data ) {

elem = elem == window ?

windowData : elem;

if( !!elem.tagName && (elem.tagName.toLowerCase() == "applet"
elem.tagName.toLowerCase() == "object") ) return false;

var id = elem[ expando ];

Compute a unique ID for the element if ( !id )

id = elem[ expando ] = ++uuid;

Only generate the data cache if we're trying to access or manipulate it if ( name && !jQuery.cache[ id ] )

jQuery.cache[ id ] = {};

Prevent overriding the named cache with undefined values if ( data != undefined )

jQuery.cache[ id ][ name ] = data;

Return the named cache data, or the ID for the element return name ?

jQuery.cache[ id ][ name ] : id;


This fixes the problem. However, I don't think this is a proper fix for the issue as there are other functons that try to access the expando object.

comment:3 Changed 15 years ago by serhii

Same problem with Applets and JQuery when unloading.

I have a test page with this bug that also crashes IE7, stopping the unloading and forcing me to terminate the IExplorer process. To reproduce the error i've taken the example from Dan Switzer and modified the div and the applet tag:

<div style="display: none;">
<object id='applet'
 width='150' height='50' mayscript='true'>
  <param name='type' value='application/x-java-applet;version=1.4'>
  <param name='code' value='HelloWorld.class'>
  <param name='archive' value='./'>
  <param name='mayscript' value='true'>
  <param name='scriptable' value='true'>


If I remove the display:none works fine on IE7. It also works when using the applet tag instead of the object tag.

We don't use jQuery to modify anything on the applets so we have changed the following lines in jquery (1.2.3):

// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events
jQuery(window).bind("unload", function() {

... to this ...

// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events
jQuery(window).bind("unload", function() {

... so we don't have errors in IE and FF.

comment:4 Changed 15 years ago by michaelm

I've been trying like every workaround I could find on the net, but the Java Applet "Jumploader" 2.8.5 (see http://www.jumploader.com/) throws errors with jQuery 1.2.6 in Firefox

Java class jmaster.jumploader.app.JumpLoaderApplet has no public field or method named "jQuery1213566312578"
var id = elem[ expando ];
jquery-1.2.6.js (line 662)
Java class jmaster.jumploader.app.JumpLoaderApplet has no public field or method named "jQuery1213566312578"
id = elem[ expando ] = ++uuid;
jquery-1.2.6.js (line 666)

This happens randomly while loading or (for example) after hiding the applet container with .hide(). If this is really supposed to be "fixed" (#1675) then I wanna know what to do about it (other than waiting and pray to god *lol*).

If I apply to workaround mentioned above, I get:

Java class jmaster.jumploader.app.JumpLoaderApplet has no public field or method named "onajaxSuccess"
if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+ty...
jquery-1.2.6.js (line 2022)

This is not much better Any hints? Other things to try?

comment:5 Changed 15 years ago by MiiJaySung

Indeed, this has stumped me for a couple of hours, because I wanted to implement a solution that didn't involve having to hack the jQuery source.

This is not just an issue for the unload event, it just so happens the unload event is what commonly manifests this error because it guaranteed to be triggered for applet/object/embed tags that are host to Java Applets. As a result the code fixes above don't really fix the root of the issue.

Here's my solution to the problem: (I haven't put in a patch attachment for now, I'll let others review the code below first)

Place this below the 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));

Then replace all bits of code where:

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

occur (about 4 times, mainly in the events section inside 'if' conditionals) with:

! jQuery.isHtmlElement(elem) 

This fix is good enough for most people, however I will admit that my isExternal() implementation leaves a little to be desired for detecting Applets. (I originally called this isApplet, but Flash, and a few other external plugins use object/embed). Object tags are supposed replace img tags in XHTML 2, therefore one probably is best to sniff the MIME/content type of the object tag to ensure it's a java applet, or flash object etc (I'm not sure if flash is giving the same issues as Java here)

comment:6 Changed 15 years ago by MiiJaySung

Also, I forgot to say my work around manages to work in the situation where you are removing / modifying HTML that hosts a Java Applet through an AJAX request.

(Without my work I had issues in MSIE where I got JS errors when an AJAX request replaced the object/embed code with something else. This was failing because the replace process would need to transverse the Applet nodes when removing them via methods such as remove/empty/html)

comment:7 Changed 15 years ago by flesler

need: ReviewPatch
Owner: set to flesler
Status: newassigned

comment:8 Changed 15 years ago by malsup

Another demo page can be found here:


MiiJaySung's suggestions do seem to fix the problem.

comment:9 Changed 15 years ago by flesler

That approach is really lengthy. I don't think we need such checks.

Just avoiding to set the expando for these 3 would do. The thing is, what do we use to generate a uid. Maybe using the id/name attribute if existent, and setting a new one if none is used.

comment:10 Changed 15 years ago by rene7705

I'm also experiencing this bug, with an FTP java applet that i must use to enable large uploads for my CMS.

I modified 1.2.6-source so that it no longer generates warnings. It's a very crude hack, but i want to share it with you anyway..

comment:11 Changed 14 years ago by glenne

I had the same problem (IE7) with 1.2.3 when exiting the page but could not modify the jQuery source in my environment. I added the following code to my javascript to cancel the regular jQuery unload event and replace it with the one suggested by serhii.

        jQuery(window).bind("unload", function() { jQuery("*:not(object):not(embed):not(applet)").add(document).unbind();});

comment:13 Changed 14 years ago by john

Component: coredata
Milestone: 1.31.4
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.