Debugging IE8 Javascript Replace innerHTML Runtime Error

前端 未结 10 1025
执笔经年
执笔经年 2020-12-09 17:33
function DeleteData(ID)
{
 var ctrlId=ID.id;

 var divcontents=document.getElementById(ctrlId).innerHTML;
 var tabid=ctrlId.replace(/div/,\'tab\');
 var tabcontents=         


        
10条回答
  •  醉酒成梦
    2020-12-09 17:52

    In IE8, you cannot change the innerHTML of an object when the code that attempts that is fired from within the object.

    For example:

    
      
    
    

    with the following code tucked in some remote corner of your document:

    
    

    This will fail with the error unknown runtime error. I believe it has to do with the fact that you're trying to replace the HTML code which fired the current line of execution. The onclick event is part of the code being replaced by the DoSomething function. IE8 doesn't like that.

    I resolved my issue by setting a timer event for 250 milliseconds, such that the function called at the end of the 250 milliseconds replaces the span's innerHTML.

提交回复
热议问题