Merge pull request #53 from jonhinson/fix/native_browsers_beforeunload

Fix error on beforeunload in browsers with native support
Mess with maxlength only if specified

It seems the previous patch was causing problems in Firefox 3.6 since it
was returning -1 for the value of the maxlength attribute if the
attribute was never supplied in the first place.

This patch tries to detect if the maxlength was supplied, and only
proceeds to manipulate it if it is present.