javascript 修复 IE8 中的“未知运行时错误”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7892102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 01:40:00  来源:igfitidea点击:

Fixing "unknown runtime error" in IE8

javascripthtmlinnerhtmlruntime-error

提问by Alex K.

I don't see anyone else really trying to accomplish what I am... LOADS of people want to replace some node via innerHTML property however, I not only want to do this but I ALSO want to replace it with javascript.

我没有看到其他任何人真的试图完成我的工作......然而,很多人想要通过 innerHTML 属性替换某个节点,我不仅想这样做,而且我还想用 javascript 替换它。

Here is my example script which is working fine in all versions of Firefox: http://syn4k.site90.net/working_test/EDIT: If the above link does not work, try this one: http://www.syn4k.freehosting.com/working_test/

下面是它在Firefox的所有版本中工作正常我的示例脚本: http://syn4k.site90.net/working_test/编辑:如果上面的链接不起作用,试试这个:HTTP://www.syn4k.freehosting .com/working_test/

You will note that it is NOT working in IE8. I'm guessing it is not working in any version of IE...

您会注意到它在 IE8 中不起作用。我猜它在任何版本的 IE 中都不起作用......

The process I have created at the link is simple: 1. The user clicks to being the process. 2. A new window is opened. 3. Data from the new window is sent back to the opener and inserted into the DOM. 3.note. The data being sent back is javacript and should execute as it does in Firefox.

我在链接中创建的流程很简单: 1. 用户点击成为流程。2. 打开一个新窗口。3. 来自新窗口的数据被发送回开启器并插入到 DOM 中。3.注意。发回的数据是 javacript 并且应该像在 Firefox 中一样执行。

回答by Alex K.

I got a look before your hosting went dowm; You cannot set innerHTMLof a scriptnode in IE, instead you need to newdiv.text = your_string_with_js;(or append a createTextNode()to it).

在您的托管失败之前我看了看;你不能设置innerHTML一个的script在IE的节点,而不是你需要newdiv.text = your_string_with_js;(或追加createTextNode()到它)。