avoid innerHTML parsing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sergey Batishchev

    avoid innerHTML parsing

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

    Set newelem = doc.createEleme nt("span")
    newelem.innerHT ML = "<a href=""test\tes t.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?
  • Martin Honnen

    #2
    Re: avoid innerHTML parsing



    Sergey Batishchev wrote:
    [color=blue]
    > I need to create element with some content inside. This may be any
    > HTML stuff - tags, text. I do next
    >
    > Set newelem = doc.createEleme nt("span")
    > newelem.innerHT ML = "<a href=""test\tes t.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?[/color]

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

    Martin Honnen


    Comment

    Working...