Reload external javascript after asynchronous postback via UpdatePanel

Posted by Protector one on Stack Overflow See other posts from Stack Overflow or by Protector one
Published on 2009-12-01T20:38:28Z Indexed on 2012/06/28 3:16 UTC
Read the original article Hit count: 279

Filed under:
|
|

I have an external javascript on my page, e.g. something like:

<script src="http://foo.com/script.js" type="text/javascript"></script>

and an UpdatePanel somewhere. The script writes some content, and does this from within an anonymous javascript function in the js file. I.e., there is something like this in the script:

(function(){document.write('content');})();

Whenever the UpdatePanel is updated through asynchronous postback, everything the script did (or any javascript on my page, for that matter) is made undone. For normal javascript, I would just use:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(myFunction)

to redo all that, but since the function in the script source file is anonymous and called upon definition, I'm SOL! Any ideas?

Note: the external js source is from another domain and its content is out of my control.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript