I have a userscript for Google Reader, and as part of that userscript I need to trigger a refresh, which I do in Firefox by simulating a keypress
for the letter r.
function simulateRefresh()
{
var e = document.createEvent('KeyboardEvent');
e.initKeyEvent('keypress', true, true, window, false, false, false, false, 82, 82);
document.body.dispatchEvent(e);
}
This works in Firefox, but not in Chrome. Apparently initKeyEvent
is not supported, and I'm supposed to use initKeyboardEvent
.
So far I've had zero luck with this (There is no error in the console, but the refresh does not fire.) I am using jQuery if that matters.
I also tried triggering click
on the refresh button, but this failed in both browsers (not sure why, the click event is firing according to the Chrome debugger, but the code is obfuscated, so I can't figure it out).