By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

avoid innerHTML parsing

P: n/a
I need to create element with some content inside. This may be any
HTML stuff - tags, text. I do next

Set newelem = doc.createElement("span")
newelem.innerHTML = "<a href=""test\test.htm"">1st</a>"

(code above is written in VB, but it does not matter)

but in saved HTML I have anchor with absolute path
<a href="file:///c:/test/test.htm">1st</a>

All I want is avoiding internal parsing of innerHTML. I found, that I
can
set anchor.href directly and it will not be parsed. But I need to
parse string with element and find "href" substring. This seem to be a
buggy way.
I prefer to do it with no workarounds, with some simple and bugs-free
way.
Is there any chance for that?
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Sergey Batishchev wrote:
I need to create element with some content inside. This may be any
HTML stuff - tags, text. I do next

Set newelem = doc.createElement("span")
newelem.innerHTML = "<a href=""test\test.htm"">1st</a>"

(code above is written in VB, but it does not matter)

but in saved HTML I have anchor with absolute path
<a href="file:///c:/test/test.htm">1st</a>

All I want is avoiding internal parsing of innerHTML. I found, that I
can
set anchor.href directly and it will not be parsed. But I need to
parse string with element and find "href" substring. This seem to be a
buggy way.
I prefer to do it with no workarounds, with some simple and bugs-free
way.
Is there any chance for that?


Try
var link = document.createElement('a');
a.href = 'test/test.html';
span.appendChild(a)
I don't see any reason to mix createElement with innerHTML assignment
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.