I have an external javascript on my page, e.g. Something like this:
& lt; Script src = "http://foo.com/script.js" type = "text / javascript" & gt; & Lt; / Script & gt;
And somewhere an UpdatePanel script writes some content, and it 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 UpdatePanel is updated via Asynchronous Postback, all scripts (or for any JavaScript on that page, for that matter) are undone For javascript, I just use it:
Sys.WebForms.PageRequestManager.getInstance (). Add_endRequest (myFunction)
To do all this again, but since the function in the script source file is anonymous and is called on definition, I am SOL! Any ideas?
Note: External JS source is from another domain and its content is outside of my control.
try it
private string _myScript = @ "(function ( ) {Var ys = document.createElement ('script'); ys.type = 'text / javascript'; ys.async = true; ys.src = 'http: //foo.com/script.js'; var s = Document.getElementsByTagName ('script') [0]; s.parentNode.insertBefore (ys, S);}); ";
Then your page_load
ScriptManager.RegisterStartupScript (this.Page, this.Page.GetType (), "myScript", _myScript, true);
No comments:
Post a Comment