I am working on the same thing and after much culling I have the following
test file:

  <head>
    <title>URL Load</title>
  </head>
  <body>
<script language="JavaScript1.2">
content = " \
MyalertCnt=0; \
Myalert=function(s){ \
    s=(MyalertCnt++)+' '+s; \
    alert(s); \
} \
 \
function BASE(){ \
} \
BASE.prototype.getClass=function(){ \
    return 'BASE'; \
}; \
BASE.prototype.XXX=function(){ \
}; \
 \
function DERIVED(){ \
    this.base=BASE; \
    this.base(); \
} \
DERIVED.prototype=new BASE(); \
DERIVED.prototype.getClass=function getClass(){ \
    return 'DERIVED'; \
} \
DERIVED.prototype.YYYY=function(){ \
}; \
 \
var baseObject = new BASE() \
Myalert('baseObject class = '+baseObject.getClass()); \
 \
var derivedObject = new DERIVED() \
Myalert('derivedObject class = '+derivedObject.getClass()); \
";
RUN = function() {
    eval(content);
}
//eval(content);
RUN();


</script>
  THIS IS THE BODY
  </body>
</html>

I started out trying to call eval() on dynamically loaded content without
success. I've reduced
to the above. When the 'content' is evaluated with the call to 'eval(content)'
in the global
context (Netscape 4.76) it works but if the call is to eval(content) within
the function
RUN(), (comment the eval statement and uncomment the call to RUN()),
then it fails - the derived object does NOT have ANY methods!!!

Now, both versions, calling eval(content) at the global level and calling
RUN(), work
for mozilla 6.1. So, there is something funky about Netscape 4.76 that behaves

differently.

This is important (assuming Netscape 4.76 is important) because dynapi is
executed in the
'onload' hook which means that any call to 'eval()' does not take place at the
global
level but rather is nested within a function.

Richard

Jim Foster wrote:

> Hello, all!
>
> I am very interested in using this technique that Michael Pemberton has
> developed, however, I am having difficulty and was wondering if Michael (or
> anyone) would be so kind as to get me pointed on the right track?
>
> Here is my code which uses Michael's setURL() technique:
> =============================================
> <html>
> <head>
> <title>Site Nav</title>
> <script language="javascript" src="javascript/dynapi.js"></script>
> <script language="javascript">
>     DynAPI.setLibraryPath('javascript/lib/')
>     DynAPI.include('dynapi.api.*')
>     DynAPI.include('dynapi.file.io')
>     DynAPI.include('dynapi.file.url')
> </script>
>
> <script language="javascript">
> DynAPI.onLoad = function() {
>     siteNavLayer = new DynLayer(0,0,400,40)
>     siteNavLayer.setURL('test.htm',false,false)   // no js, no evt
>     DynAPI.document.addChild(siteNavLayer)
> }
> </script>
> </head>
>
> <body>
> </body>
>
> </html>
> =============================================
>
> This returns a page with
>
>          [object Object]
>
> contained in the layer.
>
> I have no doubt that I am doing something wrong that is embarrasingly
> simple.
>
> Incidentally, the files referred to in the include statement are the ones
> that Michael had in his file.zip attached to his e-mail of 2/21, and the
> HTML file I am using in setURL() is the HTML equivalent of "Hello World")
> (i.e., very simple, no javascript).
>
> Please advise.
>
> -- Thanks! --
>
> ----- Original Message -----
> From: "Michael Pemberton" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, February 21, 2001 10:09 PM
> Subject: [Dynapi-Dev] Dynamic Content Loading (IT WORKS)
>
> > I now have it working in both NS and IE (only win tested) and can't see
> > any bugs. (I should open my eyes)
> >
> > Just place all the files in their own directory called "file" in your
> > libs directory.
> >
> > Then all DynLayer's will have a new method called setURL:
> >     DynLayer.prototype.setURL=function(url,js,noevt)
> >
> > url is the location of the file.
> >     this can be relative to the current main page or absolute.
> >     it MUST only be on the current domain, java does not allow external
> > server downloads
> > js
> >     do you wish any found javascript to be executed?
> > noevt
> >     do you wish the load events to be triggered?
> >
> > --
> > Michael Pemberton
> > [EMAIL PROTECTED]
> > ICQ: 12107010
> >
> >
>
> _______________________________________________
> Dynapi-Dev mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dynapi-dev


_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev

Reply via email to