jQuerify is a bookmarklet that embeds jQuery in a page.  It is very useful for playing around with jQuery in firebug and has been a basis for a new bookmarklet I have been writing.

Using the jQuerify bookmarklet, I encountered an obscure error that eluded me for many days now.

[Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame :: http://www.cnn.com/2009/CRIME/03/31/sibling.stabbings/index.html :: anonymous :: line 72" data: no]

You can easily reproduce this error on many web sites, one being cnn.com.

  1. Load the web page in FireFox with FireBug enabled
  2. Embed jQuery using the jQuerify bookmarklet
  3. In the FireBug console, type jQuery('.cssClass')

Any selector that uses a css class will throw the error.

I was able to trace the error to a conflict between jQuery and Prototype with the document.getElementsByClassName function.

Fortunately, jQuery includes well documented but often overlooked function called jQuery.noConflict().  This function reverts the $ variable back to the initially loaded library (Prototype in this case).  In addition, it appears to remove the conflict that causes the above error.

Simply call the jQuery.noConflict() function after the jQuery library is loaded to avoid the above error.

More information about using jQuery with other libraries can be found here.