我有以下代码,在Chrome、IE8和FF中都可以完美运行。但是在测试IE7时,出现了错误。有人知道这是怎么回事吗?
function do_replace(s, p1,p2,p3,child_node,syn_text) {
reg = new RegExp('[h\|H][1-7]');
if(p1.length>0){ //this might not be necessary
//create textnode
var text_node = document.createTextNode(p1);
child_node.parentNode.insertBefore(text_node,child_node); //errors out here in IE7
}
代码在最后一行出现错误- 当我通过调试器查看代码时,IE7会给出一个“htmlfile: Invalid argument.”的错误。当运行此脚本时,child_node、parentNode和text_node似乎与Firefox和Chrome形成相同。
有什么想法吗?还是说IE7不像其他浏览器那样支持这种方法?
谢谢