views:

88

answers:

1

When adding code to an onclick handler, are there any limitations to what can be done?

Can I have unlimited statements separated by ; ?
Can I declare variables that will live in the global scope?
Can I declare an anonymous function right in there and call it? (function(){})();?
Is there any limitation?

The reason I'm asking is that i'm putting a lot of code in an onclick handler, and only in IE, one variable that I'm declaring and should go to the global scope is not being found afterwards.

However, that same code does work in other browsers, and it does work in IE when I use the same code as a bookmarklet.

EDIT: The code in question is here

EDIT 2: The reason I'm making such a horrible and bulky onclick handler is that I'm making code that other people can put on their websites (think: Digg button), that will inject a script of mine. I'm trying to keep it simple for them, without cluttering their namespace too much, which is why giving them simply an <img> with an onclick handler is ideal.
If I absolutely can't make this work, then I'll have to give them code that declares a <script>, with a named function inside, and then the <img> with the onclick handler that calls that function.

Any ideas?

Thanks!

+2  A: 

Try prepending window. to AppD.

Andrew Noyes
That did it, thank you very much!!
Daniel Magliola
Long question - short Answer, and it worked :o
Rakesh Juyal