Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #10157

Cannot write to the DOM

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.190.251.MISMATCH!news-out.readnews.com!transit4.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From RH <richkhall@gmail.com>
Newsgroups comp.lang.javascript
Subject Cannot write to the DOM
Date Wed, 11 Jan 2012 21:20:32 -0800 (PST)
Organization http://groups.google.com
Lines 39
Message-ID <3437926.47.1326345632135.JavaMail.geo-discussion-forums@yqiq10> (permalink)
Reply-To comp.lang.javascript@googlegroups.com
NNTP-Posting-Host 23.17.142.64
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1326345632 21316 127.0.0.1 (12 Jan 2012 05:20:32 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Thu, 12 Jan 2012 05:20:32 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=23.17.142.64; posting-account=I26IowoAAAA18TXfHQb5fyCPJFoRuHaI
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:10157

Show key headers only | View raw


I'm a newbie, and just starting to use javascript.  I've written a small program that simply adds an element to an unordered list in the DOM:

<body>
   <form>
      <input type="text" name="filePath" size="100" />
      <button id="add_button">Add Element</button>
   </form>
   <ul id="test"></ul>
   <script language="JavaScript" type="text/javascript" src="viewer.js">      
   </script>
</body>

script in viewer.js:

window.onload = init();

function init() {
   var button = document.getElementById("add_button");
   button.onclick = create;
}


function create() {
   // create the element in the DOM
   var listItemViewer = document.getElementById("test");
	
   var test = document.createElement("li");
   test.innerHTML = "test list item";
   listItemViewer.appendChild(test);
}

If I run it and click the add button, it flashes the "test list item" on the screen - if I single step it through the debugger, it shows that it puts the element in the DOM at the end of the create() function, but then it gets stripped out?  Can anyone help me understand why this is happening?

Thanks, 

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Cannot write to the DOM RH <richkhall@gmail.com> - 2012-01-11 21:20 -0800
  Re: Cannot write to the DOM Tim Streater <timstreater@greenbee.net> - 2012-01-12 09:38 +0000
    Re: Cannot write to the DOM R Hall <richkhall@gmail.com> - 2012-01-12 18:52 -0800
  Re: Cannot write to the DOM "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-12 12:06 +0000
  Re: Cannot write to the DOM Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-12 13:21 +0100
    Re: Cannot write to the DOM John G Harris <john@nospam.demon.co.uk> - 2012-01-13 17:06 +0000
      Re: Cannot write to the DOM Gene Wirchenko <genew@ocis.net> - 2012-01-13 11:38 -0800
      Re: Cannot write to the DOM Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-13 22:23 +0100
        Re: Cannot write to the DOM John G Harris <john@nospam.demon.co.uk> - 2012-01-14 15:49 +0000
          Re: Cannot write to the DOM Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-14 17:26 +0100
            Re: Cannot write to the DOM John G Harris <john@nospam.demon.co.uk> - 2012-01-15 14:19 +0000
              Re: Cannot write to the DOM Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-15 19:45 +0100
                Re: Cannot write to the DOM John G Harris <john@nospam.demon.co.uk> - 2012-01-16 10:40 +0000
              Re: Cannot write to the DOM Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-15 20:56 +0000
  Re: Cannot write to the DOM Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-12 14:00 +0000
    Re: Cannot write to the DOM Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-12 18:32 +0100
  Re: Cannot write to the DOM RobG <rgqld@iinet.net.au> - 2012-01-17 19:26 -0800

csiph-web