Subj : Re: Rhino - How to return a function property from current stope, To : Ryan Breen From : Igor Bukanov Date : Fri Aug 27 2004 09:38 pm Ryan Breen wrote: > On Fri, 27 Aug 2004 18:03:26 +0200, Igor Bukanov wrote: > >>BTW, why do you need to support this? To emulate MSIE behavior in a >>browser? If so, how do you define document and scope in your Java code? > > > Yes, to emulate IE. This is a bit of JavaScript used to define the banner > ad at the top of www.cnn.com. > > I have a host object for all the usual suspects -- document, window, > navigator, html elements, etc. I create a top scope and defineClass each > of these host objects into that scope. I then context.newObject a top > level window from that scope and set its parent scope to null. That > window is the parent scope for its document, which is created with > context.newObject(ownerWindow, ...); > Well, if you in a business of implementing a browser that has to follow MSIE, then the advise is not to inherit from ScriptableObjects or use defineClass. Instead copy the source of org/mozilla/javascript/NativeJavaObject.java and dependable classes like JavaMemebers to some other package and start tailoring it to suite your browser needs. Trust me, at the end you save a lot of time and you will be able to implemnt stuff like document.all('x') to mean the same as document.all['x'] or document.all.x... Regards, Igor .