I understand that in IE 5.5, 6, and 7, when you modify a DOM element before it is ‘closed’, it throws an “operation aborted” error (this article has more information: http://www.clientcide.com/code-snippets/manipulating-the-dom/ie-and-operation-aborted/)
In my ASP.Net application, I am registering a client script block on the page during the page_load event. (I tried moving this code to the page_loadcomplete event or page_prerender event with no luck).
Here is my code (pretty basic):
// Checks if the handler is a Page and that the script isn't already on the Page
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("blockUIAlert"))
{
ScriptManager.RegisterClientScriptBlock(page, typeof(ScriptUtilities),
"blockUIAlert", script, true);
}
I’m using this same code from other AJAX postbacks in my page without a problem. This error only occurs if this code is called when the page is being loaded.
What can I do to have this code be called after the DOM elements are closed? I don’t want the user to have to initiate this action manually — I want this code to be executed as soon as the page is loaded, provided certain server-side conditions are met.
If you are using YUI, or jQuery they have js event listening functions that will run code when the DOM is done loading. I am betting that MS Ajax library has a similar function.
jQuery Examples