问题描述
我有这个荒谬的问题,试图设置一个
div节点的innerHTML。它适用于所有其他浏览器,但Internet Explorer是
给我一个未知的运行时错误。这实际上是在开发自动建议的背景下(基本上是逆向工程Google
建议),但是我看不出其他代码是怎么回事有事可做
吧。我非常确定*我已经将它缩小到1行(
行,其中抛出了javascript错误。以下是
行's抛出javascript错误:
[----------------------------- ------------------------
document.getElementById(''suggest_box'')。innerHTML = listings ;
------------------------------------- ----------------]
其中listing是使用XmlHttpRequest对象获取的html代码
a远程PHP文件。我做了一个警报(列表)和一个
" alert(document.getElementById(''suggest_box'')。inne rHTML)就在
错误行,果然,列表显示它确实设置了
,并且suggest_box节点确实存在。我的大脑被炒了
从试图弄清楚这件事。我会喜欢任何人对此有任何建议/评论谢谢!
也许"选不是字符串而是对象吗?
你可以尝试:
document.getElementById(''suggest_box'')。innerHTML =''''+上市;
-
Evertjan。
荷兰。
(全部替换在我的电子邮件中穿过圆点)
也许是列表你不是一个字符串而是一个对象吗?
你可以尝试:
document.getElementById(''suggest_box'')。innerHTML =''''+ listing;
-
Evertjan。
荷兰。
(用我的电子邮件中的点替换所有十字架)
By任何机会 - 也许吧你的列表包含表格的HTML代码?
I am having this ridiculous problem of trying to set the innerHTML of a
div node. It works in all other browsers, but internet explorer is
giving me an "Unknown runtime error". This is actually in the context
of developing an auto-suggest (basically reverse-engineering Google
Suggest), but I don''t see how any of the other code has anything to do
with it. I *pretty sure* that I''ve narrowed it down to 1 line (the
line on which the javascript error is being thrown. The following is
the line that''s throwing the javascript error:
[-----------------------------------------------------
document.getElementById(''suggest_box'').innerHTML = listings;
-----------------------------------------------------]
where "listings" is html code gotten using the XmlHttpRequest object on
a remote PHP file. I do an "alert(listings)" and a
"alert(document.getElementById(''suggest_box'').inne rHTML)" right before
the error line and sure enough, the listings is showing that it is
indeed set, and the suggest_box node indeed exists. My brain is fried
from trying to figure this thing out. I would love any
suggestions/comments anybody has about this. Thanks!
perhaps "listings" is not a string but an object?
Could you try:
document.getElementById(''suggest_box'').innerHTML = '''' + listings;
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
perhaps "listings" is not a string but an object?
Could you try:
document.getElementById(''suggest_box'').innerHTML = '''' + listings;
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
By any chance - maybe your "listings" contains HTML code for a table?
这篇关于node.innerHTML ='...'在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!