I'm not sure why your script register is not working, but you tried to put a javascript call directly on the page inside the script block? If this works, wrap the script block in the panel at the bottom of the page with visible = "false". In your code, when you determine that you want it to work, set the visibility to true.
If you are using jQuery, I would also wrap the contents of your script block in:
$(document).ready(function() {
Just to make sure it is not called before the page can process it.
All of this assumes, of course, that your function call is good and that the problem is with the script registration client.
source share