I can't resist mentioning another trick, which helps if you have an unknown number of arguments that are also being passed as part of the string containing the function name. For example:
var annoyingstring = 'call_my_func(123, true, "blah")';
If your Javascript is running on a HTML page, all you need is an invisible link; you can pass a string into the onclick
attribute, and the call the click
method.
<a href="#" id="link_secret"><!-- invisible --></a>
$('#link_secret').attr('onclick', annoyingstring);$('#link_secret').click();
Or create the <a>
element at runtime.