[Greasemonkey] Using functions in JavaScript Includes

Richard Wallis Richard.Wallis at talis.com
Thu Aug 18 17:09:50 EDT 2005


Hi,

I want to be able to reuse a set of functions in several Greasemonkey
scripts.  To keep things simple I want to create a utils.js script file
to keep them in and then load that file in each xx.user.js.

For test purposes here is the contents of utils.js:

//GM_log("Hi");
function fun1(){
	//GM_log("F1");

	alert("<H1>Hello world</H1>");
}

I would expect that document.write("<script
type='application/x-javascript'
src='http://myserver.com/scripts/utils.js'></script>"); would load the
file for me.  I know it does because if I uncomment the GM_log() I get a
not defined error.

If I try to call fun1(); from my .user.js script I get a not defined
error.

Any ideas if what I want to do is possible, and if it is what is my
problem.
 
Talis Insight - Register now to receive your early bird discount
http://www.talis.com/insight2005/

Any views or personal opinions expressed within this email may not be those of Talis Information Ltd. The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.


More information about the Greasemonkey mailing list