Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / October 2007

Tip: Looking for answers? Try searching our database.

How can I automatically ignore script error parsing JScript?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Shearer Cooper - 24 Oct 2007 00:15 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.