Change them all to uppercase or lowercase, and compare them.
IndexOf the character position of the substring for the first time within the object
With toLowerCase or toUpperCase
<script> var teststr = ' ABCDEF '; var subStr = ' BCD '; Alert (Teststr.tolowercase (). IndexOf (Substr.tolowercase ())); Teststr = ' AbCdEf '; Alert (Teststr.tolowercase (). IndexOf (Substr.tolowercase ())); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
<script> String.prototype.indexOf = function (f,m) {var mm = (M = = False)? "I": ""; var re = eval ("/" + F + "/" +mm); var RT = This.match (re); return (RT = null)? -1:rt.index; var test = "Absnegkiugfkalg"; Alert (Test.indexof ("Kiu", false)); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Look at me this, compatible with the original indexOf <script language= "JavaScript" >/* Author: Ox (New Kunliang) qq:273352165 msn:niukl@hotmail.com statement: Free to use , please keep this information if you have any amends, remember to tell me! * * String.prototype._indexof = String.prototype.indexOf; String.prototype.indexOf = function () {if (typeof (Arguments[arguments.length-1))!= ' Boolean ') Return this._indexof.apply (this,arguments); else {var bi = arguments[arguments.length-1]; var thisobj = this; var idx = 0; if (typeof (Arguments[arguments.length-2]) = = ' number ') {idx = Arguments[argume NTS.LENGTH-2]; Thisobj = this.substr (idx); var re = new RegExp (arguments[0],bi? ') I ': '); var r = Thisobj.match (re); return r==null?-1:r.index + idx; } alert ("Bcssssasdfsdf". IndexOf (' A ', 3,true)); ALert ("Bcssssasdfsdf". IndexOf (' A ', 3)); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]