IE中的Javascript对象预期错误

时间:2017-06-09 04:44:59

标签: javascript internet-explorer

我正在接收

  使用以下代码

“对象预期错误”。当带有“a7.write(a5);”的行被调用时,会显示错误。

有什么建议可能出错吗?

function _fullChange() {
  if (parent._pprRequestCount > 0) {
    parent._pprRequestCount--;
    if (_agent.isIE) {
      var a0 = _getElementById(document, '_pprDisableWrite');
      a0.text = 'var _pprDocumentWrite = document.write;' +
      'var _pprDocumentWriteln = document.writeln;' +
      'document.write = new Function(\'return;\');' +
      'document.writeln = new Function(\'return;\');';
      var a1 = _getElementById(document, '_pprEnableWrite');
      a1.text = 'document.write = _pprDocumentWrite;' +
      'document.writeln = _pprDocumentWriteln';
    }
    var a2 = document.body;
    var a3 = a2.getAttribute('onload');
    var a4 = a2.getAttribute('onunload');
    a2.setAttribute('onload', _getCommentedScript(document, ('_pprFullOnload')));
    a2.setAttribute('onunload', _getCommentedScript(document, ('_pprFullOnunload')));
    var a5 = _getDocumentContent();
    var a6 = new RegExp('<script id=["]*_pprFullChange.*>_fullChange\\(\\)</script>', 'i');
    a5 = a5.replace(a6, '');
    a2.setAttribute('onload', a3);
    a2.setAttribute('onunload', a4);
    var a7 = parent.document;
    if (_agent.isIE) {
      var a8 = document.charset;
      a7.open();
      a7.charset = a8;
    }    
    // <<<< OBJECT EXPECTED eRROR IS PRODUCED HERE>>
    a7.write(a5);
    a7.close();
  }
}

我应该添加,当以下行被注释掉时,我们会得到相同的错误

 //if (_agent.isIE) {
      var a8 = document.charset;
      a7.open();
      a7.charset = a8;
 //}    
   a7.write(a5);

Object expected error is reported on the last line

0 个答案:

没有答案