Groups | Blog | Home
all groups > dotnet jscript > april 2005 >

dotnet jscript : Jscript conversion


Bruce Barker
4/13/2005 3:24:55 PM
jscript.net does not run in the browser, except as a hosted .net control
(active/x). this would be quite a rewrite, as talking to the browser thru a
hosted control is different, and catching events is even harder. for this
effort, you might as well make a smart client


-- bruce (sqlwork.com)


[quoted text, click to view]

Peter & Anita Nikelski
4/13/2005 11:30:45 PM
Hi,

I have a jscript client application which communicates with a J2EE backend.
The jscript client runs within IE and is actually an entire framework
consisting of over 99,000 lines of jscript code. As you can image, the
browse performance is poor and memory consumption is high.

Is it possible to migrate from regular jscript (within a browser) to
jscript.net? The idea of compiling the jscript is appealing but I don't
want to rewrite the application either.

Thanks, Peter

Serge Baltic
4/21/2005 7:53:49 AM
bb> jscript.net does not run in the browser, except as a hosted .net
bb> control (active/x).

The difference is that you do not open the page in a browser, but you rather
have to start a browser on your own.

You may use either:
• IE's Application object to open a new window.
• A WindowsForm form with an ActiveX control hosted on it.
• Use IE's showHtmlDialog method to display a modal window with your app.

Note that depending on the way you do it you will have either Internet security
zone or a Trusted one. In the latter case you have to pay much attention
to the safety of your actions executed in the browser.

bb> this would be quite a rewrite,

Something has to be changed, definitely, but if he's lucky enough then it
would be a matter of regexp replace in most cases.

bb> as talking to the
bb> browser thru a hosted control is different,

Negative. It's EXACTLY the same thing, in all the three above-listed cases:
you just get the HTML document object, from it you may have window, or get
any of the elements, and so on.

As JScript.NET supports late binding, there's also no need in imports/references
to MSHTML.tlb.

bb> and catching events is
bb> even harder.

Negative. If you use a .NET event proxy class for that, it's kinda some hell.
But for JScript.NET it's no problem and is EXACTLY the same as in JScript
of IE: you take a delegate (the Function object in JScript, that is) and
assign it to the onsomething property, or call attachEvent on the object
you want to listen to. Like:

someElement.attachEvent("onclick", clickHandler);

— where clickHandler may be a standalone function or a member of your class.
To get the event args, take your good old HTML document object, take its
parentWindow, and then the event property of it (just like it's done in IE,
but there window object properties are made global and you just type "event"
and use it).

bb> for this effort, you might as well make a smart client

Depends on the code. If it can be reused (no hardcore tricks) — then just
do it. Maybe the /fast- compiler option will help you as well.

(H) Serge

AddThis Social Bookmark Button