简体   繁体   English

Internet Explorer 8中的大写标签

[英]Uppercase tags in Internet Explorer 8

I have an HTML manipulation issue that manifests itself only in IE8. 我有一个HTML操作问题,仅在IE8中表现出来。

I had recently written some javascript that analysed a tag and did something depending on what it was. 我最近写了一些JavaScript,该Javascript分析了标签并根据标签的内容进行了处理。

The piece of code assumed the tag was in lowercase. 这段代码假定标签是小写的。

if(value.indexOf('<input') == -1)

This failed under IE8 and I have to fix it. 在IE8下失败了,我必须修复它。

Now I could and a second check as follows: 现在,我可以进行第二次检查,如下所示:

if(value.indexOf('<input') == -1 && value.indexOf('<INPUT') == -1)

This will catch both possibilities, but seems awfully messy. 这将抓住两种可能性,但看起来非常混乱。

Is there a better way to deal with this situation? 有没有更好的方法来处理这种情况? Could JQuery deal with this? JQuery可以处理吗?

"value" is an html string passed to my javascript function from JQGrid. “值”是从JQGrid传递到我的javascript函数的html字符串。 Using IE8 the string is uppercase, using IE9, FF, Chrome, it is lowercase. 使用IE8,字符串为大写,使用IE9,FF,Chrome,则为小写。

这应该可以解决问题:

if(value.toLowerCase().indexOf('<input') == -1)

Use 采用

if(value.toLowerCase().indexOf('<input') == -1) { ... }

or 要么

if(!/\<input/i.test(value)) { ... }

The latter being a regular expression with the ignore case flag set. 后者是设置了忽略大小写标志的正则表达式。

Depending on your situation obviously you could also use jquery .is() function to test for an element http://api.jquery.com/is/ 显然,根据您的情况,您还可以使用jquery .is()函数测试元素http://api.jquery.com/is/

for instance 例如

$target.is("input")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Internet Explorer 8-SCRIPT87:无效的参数-大写字母 - Internet explorer 8 - SCRIPT87: Invalid argument - Uppercase letters 如何为脚本标签检测Internet Explorer 10? - How to detect Internet Explorer 10 for script tags? 使用脚本标记检测Internet Explorer上的xml加载失败 - Detect xml load failure on Internet Explorer using script tags HTML5 <audio> 标记在Firefox和Internet Explorer上不起作用 - HTML5 <audio> tags donesn't work on Firefox and Internet Explorer 使“标签”标签在Internet Explorer 6中工作(用于单选按钮) - Getting “Label” tags work in Internet Explorer 6 (for radio buttons) jQuery - 在使用 append() 附加子节点时 - 附加的 xml 标签在 Internet Explorer 11 中转换为小写 - jQuery - On appending child node using append()- appended xml tags are converted to lowercase in Internet Explorer 11 <a>在触摸屏上进行选择时,</a>如何<a>在Edge和Internet Explorer中的标签</a>上删除永久性的工具提示 - How to remove permanent ToolTip on <a> tags in Edge and Internet Explorer when selecting on touchscreen Internet Explorer 上的 Javascript - Javascript on Internet Explorer Internet Explorer悬挂问题 - Internet explorer hanging issue 页面不会在Internet Explorer中居中 - Page will not center in Internet Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM