IE9中的Javascript错误“SCRIPT5022:DOM异常:INVALID_CHARACTER_ERR(5)” [英] Javascript Error in IE9 "SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5)"

查看:300
本文介绍了IE9中的Javascript错误“SCRIPT5022:DOM异常:INVALID_CHARACTER_ERR(5)”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在IE9中进行调试时,它会在以下行中断

{var c=document.createElement('<iframe id="'+a+'" name="'+a+'" />')

,出现以下错误:

SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5) 
wmd.js, line 1 character 97

我使用的是OSQA软件,并且可以使用最新版本的IE9(可能安装了Web开发人员工具栏)重现该错误。

I am using OSQA software, and the bug may be reproduced with the latest version of IE9 (possibly with web developer toolbar installed)

http://meta.osqa.net/questions/ask/ (错误可能会于2012年3月3日起复制)

http://meta.osqa.net/questions/ask/ (bug may be reproduced as of 1/3/12)

如果您访问该页面,打开javascript控制台,并尝试使用图像上传器上传任何图像,则会发生错误。

If you visit that page, open up the javascript console, and attempt to upload any image using the image uploader, the error occurs.

这只会因某种原因在IE9上中断

This only breaks on IE9 for some reason

我对这个javascript调试业务有点新,但是我打开了监视菜单,a的值是: jUploadFrame1325624808664

I'm a bit new to this javascript debugging business, but I opened up the watch menu and the value of "a" is: jUploadFrame1325624808664

推荐答案

createElement 方法期望要创建的元素名称。像这样:

The createElement method expects only the name of the element to create. Like this:

var c = document.createElement("iframe")

以后可以将属性添加到新元素中:

Properties can be added to the new element later:

c.id = c.name = a;

IE的早期版本允许您使用任意HTML提供此功能,但这绝不是规范的一部分,而且是IE9不再支持。

Previous versions of IE allowed you to provide this function with arbitrary HTML, but that was never part of the spec and is no longer supported in IE9.

这篇关于IE9中的Javascript错误“SCRIPT5022:DOM异常:INVALID_CHARACTER_ERR(5)”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆