【问题标题】:createElement error in IE8IE8 中的 createElement 错误
【发布时间】:2011-08-05 13:41:35
【问题描述】:

我在 IE8 中的以下行中收到跟随错误(不在 IE9 或 chrome 或 firefox 中)

popup = document.createElement('div');

错误:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Fri, 5 Aug 2011 13:39:41 UTC


Message: Object doesn't support this property or method
Line: 72
Char: 5
Code: 0
URI: http://192.168.7.1/fquick/script.js

我该怎么做?

【问题讨论】:

  • 这段代码是在 iframe 还是其他窗口中?
  • 您可能在加载文档树之前调用了 document.createElement 函数。尝试将脚本放在窗口加载功能上
  • 该错误的根源不是您提到的那一行。即使 MSIE 落后于某些事情,它肯定知道 document.createElement()
  • @jerjer - 它的固定,奇怪..thanx反正..答案在下面
  • 尝试检查文档 ==> 是否没有被另一个变量覆盖。尝试搜索“document="

标签: javascript internet-explorer-8 createelement


【解决方案1】:

将行改为

var popup = document.createElement('div');

它有效。好笑。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-22
    • 1970-01-01
    • 1970-01-01
    • 2021-11-30
    相关资源
    最近更新 更多