本文介绍了.contains(key)无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! hi 当尝试执行此操作时,我会发生错误,如0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'包含'但它适用于其他浏览器可以任何人帮助我 for ( var i = 0 ; i < = dealVar.length; i ++){ if (dealVar [i]!= null && dealVar [i] .contains(' key')){ var option = document.createElement(' option'); var str = dealVar [i] .split(' ,); var str1 = str [ 0 ] .split(' :'); var str2 = dealVar [i + 1] .split(' :); option.setAttribute(' value',str1 [ 1 ]); option.appendChild(document.createTextNode(str2 [ 1 ])); element1.appendChild(option); } } 解决方案 JavaScript数组的包含方法是一种非标准方法(它来自于ECMA)! 有一种古老而好的方法叫做 indexOf [ ^ ]支持所有浏览器,包括IE(9 +)...... hiWhen trying excute this i ma gertting error like0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'contains' but it works in other browser can any one help me outfor (var i = 0; i <= dealVar.length; i++) { if (dealVar[i]!=null && dealVar[i].contains('key')) { var option = document.createElement('option'); var str = dealVar[i].split(','); var str1 = str[0].split(':'); var str2 = dealVar[i+1].split(':'); option.setAttribute('value', str1[1]); option.appendChild(document.createTextNode(str2[1])); element1.appendChild(option); }} 解决方案 JavaScript Array's contains method is a non standard method (it comes from the proposal of ECMA)!There is an old and good method called indexOf[^] that supported in all browsers including IE (9+)... 这篇关于.contains(key)无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-06 17:29