[thelist] DHTML questions...

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Nov 15 10:16:06 CST 2001


> > First question - how to use a function to set variables. I have the
> > following set up as a function -
> >
> > function locateBox(top_loc,left_loc)
> >     {
> >     return top_loc;
> >     return left_loc;
> >     }
>
>First point, you need to understand variable scope.  These are local
>variables, their scope being within the function only.

So? Their values are returned, not the variables themselves. However, it is 
of course impossible to have two return statements, the first one ends the 
function.

> > When clicking an image, I want to update the top_loc & left_loc 
>variables
> > using:
> >
> > onclick="locateBox(50,90)"
>
>In order to relocate the div dynamically, you will have to write/use a
>cross-browser wrapper, and then manipulate the div through the Document
>Object Model (DOM). Unfortunately the DOM is different for different
>browsers, hence the need for the wrapper.

See http://www.xs4all.nl/~ppk/js/index.html?dhtmloptions.html for a very 
simple cross-browser DOM wrapper. This is not a reason not to use DHTML.

> > This should update a <div> style with the appropriate numbers and move 
>my
> > box on the map using the following:
>
>You should hard-code the div tag initially unless there is a compelling
>reason not to. Then use the DOM to change the CSS properties.

Yes, that would be best.

> > Now, second question - even should I get this working, am I
> > headed down the
> > wrong path??? Take a look at
>
>Utterly, IMHO.

I disagree. I think it's a very good idea. It's simple, everyone understands 
and it's very easy to implement. The hardest part will be calculating all 
the coordinates, but that's one two hour session, and afterwards it works.

> > which is using javascript to create the <div> tag - works fine 'n dandy 
>in
> > Explorer, but not in Netscape (v4.7) - why, oh why??? This works
> > in Netscape
> > with standard html but now when generated with javascript.
>
>Not that I've checked, but I would imagine that the reason for this is that
>NS 4.7 does not support the writeIn method, FWIW.

No, that's not true. It is the document.writing of inline style elements, as 
I said before.

I think this is a good idea, but the page should be rewritten to take a more 
generic approach to placing the box.

ppk

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





More information about the thelist mailing list