What tutorial is that? That's not standard Greasemonkey style at all, and won't work properly because of security restrictions <http://wiki.greasespot.net/UnsafeWindow>.

Much better is something along the following lines:

function helloWorld() {
    alert('hello world');
}
window.setTimeout(helloWorld, 60);


Note the use of the function's name as a symbol directly (rather than inside a string) and without calling it (there are no parentheses immediately following its reference in setTimeout). That saves a reference to the function object itself for setTimeout to call. (This works in ordinary JavaScript too; it's not a GM-specific feature at all.)

On 2010-04-15 19:38, Will Tran wrote:
Hey. This is installing properly, but javascript won't run properly
for me. I am on a Mac with Firefox 3.6.3. I tried doing
window.helloworld = function() from the tutorial and do a setTimeout.
I keep getting an error that helloworld is not defined.

window.helloworld = function() {
      alert('hello world');
};

window.setTimeout('helloworld()', 60);
--
cc | pseudonymous |<http://carlclark.mp/>


--
~ If I am nobody and nobody is perfect does that mean that I am perfect? Yes, yes, it does. ~ http://tagzilla.mozdev.org v0.066

--
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to