HtmlPage.Window.CreateInstance and [ScriptObject_TypeDoesNotExist]

When you use HtmlPage.Window.CreateInstance to invoke a JavaScript function and the function fails you get an ArgumentException with description [ScriptObject_TypeDoesNotExist] or Type ‘…’ does not exist. Parameter name: typeName.

Unfortunately this is the same error you get when the JavaScript function cannot be found in the current scope, e.g. when the page is not yet fully loaded or the function lives in another iframe or containing page.

I would suggest using HtmlPage.Window.Invoke instead as this will not give a misleading error, though still not very specific.

Advertisements