Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: using "this" in javascript/XHTML

From: Mike Kamermans <mopaxian@-------.--->
To: NULL
Date: 11/1/2004 8:07:00 PM
Using event certain made things work.. =D

I don't suppose you'd know why the following code doesn't get rendered? I 
call a replace function using an onload event in the body, which passes 
the entire xml document as event (I had expected to get the body node, 
but this also works I suppose). So I have in the xml:

<body onload=replace(event)>

And then in the js file I have a replace function that does this:

function replace(e) {
  xmldoc = e.target;
  replacenodes = xmldoc.getElementsByTagName('replace');

  //forward traversal insert
  for(var i=0;i<replacenodes.length;i++){
    imnode = xmldoc.createElement('img');
    imnode.setAttribute('src','add.gif');
    var node = replacenodes[i];
    var pnode = node.parentNode;
    pnode.insertBefore(imnode,node);
  }

  //reverse traversal delete
  for(var i=replacenodes.length-1;i>=0;i--){
    replacenodes[i].parentNode.removeChild(replacenodes[i]);
  }
}

Now, this works, in the sense that <img src="add.gif"> elements get added 
to the source (using a css file to draw the img elements as boxes for 
instance shows boxes where they should be), but unlike for instance 
adding an element called "p", and it consequently being rendered as a 
paragraph upon insertion, the "img" element does not get rendered as an 
image... 

Any clues?

Much oblidged,

- Mike Kamermans
www.nihongoresources.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent