Justin,

A bit muddled by the DOM so was interested in your urls, wonder if you can
help with another muddle here.

I put

 document.getElementById('myimage').style.left = 100;
<img src="images/cb_03.gif" name="myimage" width="90" height="65"
id="myimage" />

The above works but confuses me cause the element id, "myimage", shouldn't
work as it has not been declared until the following line. If I reverse the
above lines, it won't work. Next question I have is on
http://www.xs4all.nl/~ppk/js/dhtmloptions.html he has across browser api I
cant get to work due to my muddled knowledge of dhtml. He has the following
code for his example, what I simply want to do is make the relevant
substitutions in his example code below to be able to access "myimage" above
and apply style.left=100; as in the above, do I replace name with myimage
below, if so how do I apply the style attribute style.left = 100;
_______________________________
"This is the simplest version, without a check for nested layers in Netscape
4.

function getObj(name)
{
  if (document.getElementById)
  {
        this.obj = document.getElementById(name);
        this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
        this.obj = document.all[name];
        this.style = document.all[name].style;
  }
  else if (document.layers)
  {
        this.obj = document.layers[name];
        this.style = document.layers[name];
  }
}

It's called like this:

var x = new getObj('layername');

Now the function create a new JavaScript object x. It goes through all
possible DOMs and if it finds the one that the browser supports it sets
this.obj and this.style. The this keyword makes sure that the two properties
obj and style are added to the new object x."

____________________________________________________________________

Any help with above appreciated


TIA


Colm



-----Original Message-----
From: Justin MacCarthy [mailto:[EMAIL PROTECTED]]
Sent: 14 January 2003 17:51
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] answer to the DOM question


Here is a good up-todate guide to this stuff

http://www.xs4all.nl/~ppk/js/events_advanced.html

usual story - mozilla support DOM &  microsoft sucks...

mozilla method

addEventListener("click",myfunction,false)

http://www.mozilla.org/docs/dom/domref/dom_el_ref31.html#1028304

microsoft

attachEvent("onclick",myfunction)

ho hum

Justin


>>>>  I got a DOM/JS/x-browser question. I have a function that
> > > adds a button to a form using DOM.  I also what to add a
> > > onclick event to the button to run a function...
> > >
> > > here it is
> > >
> > > <script>
> > > function AddButton()
> > > {
> > >         var myinput= document.createElement("input");
> > >         myinput.setAttribute("type","button");
> > >         myinput.setAttribute("value","go");
> > >         myinput.setAttribute("onclick",function ()
> > > {alert('x')}); // line to change
> > >
> > >         document.getElementById("myform").appendChild(myinput);
> > >
> > > }
> > > </script>


--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.441 / Virus Database: 247 - Release Date: 1/9/2003

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.441 / Virus Database: 247 - Release Date: 1/9/2003


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to