Hi, > How about using document.write() to write the butotn dynamically into > the page. That is supported by all.
Well in case it would innerHTML() or something. Yes it would work, but I like to keep as close to DOM as possible. > How about doing a quick browser if/else check which will run whichever of > the lines you have for the correct browser? Yeap. Workable. Like to avoid it though. Maybe the fact I haven't done any HTML/DOM/Js or ages has made me idealistic !!! Thanks! Justin > > -----Original Message----- > > From: Justin MacCarthy [mailto:[EMAIL PROTECTED]] > > Sent: 14 January 2003 15:53 > > To: [EMAIL PROTECTED] > > Subject: [ cf-dev ] ot-ish DOM question > > > > > > Hi guys > > > > 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> > > > > now this version works in IE5+ but doesn't in mozilla. If I > > change the [line to change ] above to > > > > myinput.setAttribute("onclick","alert('whatever')"); // line to change > > > > it works in mozilla. > > > > Anyone know a x-platform way to add a javascript function the > > the onclick event using DOM? thanks Justin > > > > > > -- > > ** 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] > > > > > > > > -- > ** 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] > > > > -- ** 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]
