I am writing a browser plug-in for Firefox(Greasemonkey), Opera and Chrome in Javascript for a website. The issue is, when I load the document.innerHTML into a variable,
<form name="foo" action="foo.php" method="get">
<td id="td">text:
<input name="k" type="text" />
</td>
</form>
… the original code above of the website(which I am writing the plug-in for) is converted into
<form name="foo" action="foo.php" method="get">
<td id="td">text:
**<input name="k" type="text">**
</td>
… this one. As you can see, the self-closing <input /> tag is not closed anymore, and the </form> tag also disappeared. I have googled almost all the internet but none of the solutions I read did not solve my problem.
The closing
</form>tags show up for me in Firefox when getting.innerHTML.I’d suggest that the missing tag is due to your markup which I’m pretty sure is invalid:
The parent of a
<td>element should be a<tr>, not a<form>.Given this markup:
…Firefox gives me this
innerHTMLfor the<table>:It attempts a correction of the invalid markup.
DEMO: http://jsfiddle.net/grM4c/