HighDots Forums  

Re: insert element in DOM

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: insert element in DOM in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ivo
 
Posts: n/a

Default Re: insert element in DOM - 07-05-2004 , 04:15 PM






"Brian" wrote
Quote:
insertBefore method. I added a function to the mktree.js script, but
it failed to insert the button I created. However, Firefox's javscript
console did not report an error. AFAICS, it didn't find the element
with id="root".

I made a second page, this time putting the script to insert the
button inside the page itself, and it worked. I'm confused why the
funtion fails in the external js file, not inside the html document.

The test cases can be found here:

http://www.tsmchughs.com/test/insert/
Simple. In your external file the code responsible for adding the button is
called before the page renders, before there is an element with id=root. Run
it onload and you should be fine. In the internal version, the button code
is placed at the end, when the element is there already.
Also,
newButton = document.createElement("BUTTON");
newButton.setAttribute("type", "button");
seems odd. What other type can a button be?
HTH
Ivo




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.