Echoing other responses I don't know quite what you're asking here. In particular never say "it doesn't work - state what actions you performed, what your expected output was and what your actual output was. Though anyway:
- You shouldn't use a
javascript:
prefix in a href; you should actually use the onclick event that you referenced in your question title.
- You can just use
xmldoc
and rootnode
unprefixed.
- If you don't want the hyperlink to actually go anywhere, make sure you
return false
from the onclick handler to prevent the click from being handled. Also set the URL to "#" (which will typically point to the top of the current page), so that the link will degrade gracefully with Javascript disabled and so that the address in the status bar on hover makes sense (unless you want to override that too).
- I hope that code ends abruptly, since looping over all elements just to perform some action on the first one is suboptimal, to say the least.
Thus I believe your last line could be written as
pagesref = pagesref+"<a href='#' onclick='newsdatainfo(xmldoc,newsresult,6,10); return false' >"+p+"</a> | ";
and things might work as you expect, however that may be.