[Greasemonkey] Re: Clicking a Button Programmatically
A. Alfred Ayache
alfred at lastbyte.ca
Wed May 24 21:50:34 EDT 2006
Thanks, Mark and everyone else.
Mark, if this isn't the right pattern, what is? All I need at this point is an
easy way to click the button.
Thanks again,
A. Alfred Ayache
http://lphs76.ca - Reunion community
http://www.rentersPlus.com - Apartment Search
http://www.lastbyte.ca - Web Design, eCommerce, PHP/MySQL, Java, Oracle
Mark Pilgrim wrote:
> On 5/24/06, A. Alfred Ayache <alfred at lastbyte.ca> wrote:
>> HTMLInputElement.prototype._click =
>> HTMLInputElement.prototype.click;
>> HTMLInputElement.prototype.click = newclick;
>>
>> refbtn.click();
>> <<<
>>
>> The original example used the HTMLFormElement class. Since the target
>> page used
>> a button input element, I switched to HTMLInputElement. Sadly, not
>> only did
>> this not work, but I got the following error:
>>
>> Error: HTMLInputElement.prototype has no properties
>
> Yeah, this broke after the book was published (specifically, it broke
> in GM 0.6). Now you need to use
>
> unsafeWindow.HTMLInputElement.prototype._click =
> unsafeWindow.HTMLInputElement.prototype.click;
>
> unsafeWindow.HTMLInputElement.prototype.click = newclick;
>
> I'm not sure that overriding the click method is really what you want
> in this particular script, but that's the corrected pattern for
> overriding methods of DOM Element classes.
>
> This pattern is put to good use here:
>
> http://kailasa.net/prakash/greasemonkey/post-interceptor.user.js
>
More information about the Greasemonkey
mailing list