Sorry for the cross-post, but I don't know which is the right group for this
question.
I have some JScript macros that I execute inside of my MFC/C++ Windows
program by calling CoCreateInstance(CLSID_JScriptEngine, ...,
IID_IActiveScript), getting the IID_IActiveScriptParse interface, and
calling its ParseScriptText() function (and a lot more steps that don't seem
relevant to this question).
Inside the JScript macro is code like this:
var oDoc = new ActiveXObject("htmlfile");
oDoc.open();
oDoc.write(HtmlText);
oDoc.close();
I'm doing this so I can use the "htmlfile" object to parse the contents of
my HtmlText variable (which is the HTML of a web page that I've acquired
elsewhere).
The problem is, sometimes the HTML contains references to JScript defined on
other web pages - like <script type="text/javascript"
src="http://fakepage.com/js/functions.js"></script> which is fine, I don't
expect the "htmlfile" object to load those external web pages, but then the
parser gets upset because there will be calls to functions defined on those
external web pages - like <script
type="text/javascript">externalFunction();</script>. I can understand the
parser not being able to execute that JScript, the problem is that the user
has "Disable script debugging" turned off, and as a result the user gets
this nasty dialog popping up in the middle of things, saying there has been
a JScript error, do they want to debug. Because this is happening at user
sites, I can't require that they all turn on "disable script debugging".
Is there a way to tell IActiveScriptParse, or IActiveScript, or
JScriptEngine, to
1) not worry if it can't fully parse JScript embedded in the HTML
or
2) not display the dialog telling the user there was a problem with the
JScript
or
3) use some pseudo-debugger that I've created, rather than bothering the
user with the error message
Thanks,
Chris
Joe Fawcett - 24 Oct 2007 12:44 GMT
> Sorry for the cross-post, but I don't know which is the right group for
> this question.
[quoted text clipped - 42 lines]
> Thanks,
> Chris
Well in a normal browser window you could cancel the error by providing a
function for the window.onerror event. I don't know how you do this in your
situation other than add such a script block to the HtmlText first..
My other thought is to remove the script blocks from HtmlText altogether. A
simple regular expression should be able to hunt them out.

Signature
Joe Fawcett (MVP - XML)
http://joe.fawcett.name