<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>blank</title>
<script type="text/javascript">
var TextNode = {
each: function(callback, parent) {
for (var childNodes = (parent || document.body).childNodes, i = 0, length = childNodes.length; i < length; i++) {
var I = childNodes[i];
/*if (I) */I.nodeType == 1
? arguments.callee(callback, I)
: I.nodeType == 3 && callback(I, i);
}
}
};
window.onload = function() {
TextNode.each(function(noda) {
var div = document.createElement('div');
div.innerHTML = noda.nodeValue.replace(/(http\:\/\/www\.youtube\.com\/watch\?v\=[0-9a-z]{11})/gi, '<a href="$1">$1</a>');
var f = document.createDocumentFragment();
//if (div.firstChild) {
while (div.firstChild)
f.appendChild(div.firstChild);
noda.parentNode.replaceChild(f, noda);
//}
});
/*TextNode.each(function(noda) {
var div = document.createElement('div');
div.innerHTML = noda.nodeValue.replace(/(http\:\/\/www\.youtube\.com\/watch\?v\=[0-9a-z]{11})/gi, '<a href="$1">$1</a>');
if (div.firstChild && div.innerHTML != noda.nodeValue) {
var f = document.createDocumentFragment();
do f.appendChild(div.firstChild);
while (div.firstChild);
noda.parentNode.replaceChild(f, noda);
}
});*/
};
</script>
</head>
<body>
<form>
<input type="text" />
<input type="text" />
</form>
</body>
</html>
При этом если форму записать в одну линию, то ошибка исчезает:
<form><input type="text" /><input type="text" /></form>