Created
July 1, 2015 01:25
-
-
Save JavaScript-Packer/c48da237cc2e2a5baea7 to your computer and use it in GitHub Desktop.
IE web browser often won't handle indexOf() command in JavaScript (Jscript is IE's engine or coding for Jscript.net), so here is an alternate function: http://jsfiddle.net/ccxqosxn/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myIndexOf(a, b) { | |
var c, d, e = a.length, f = b.length; | |
for (c = 0; e > c; c++) { | |
for (d = 0; f > d && a[c + d] == b[d]; d++) ; | |
if (d == f) return c; | |
} | |
return -1; | |
} | |
//USAGE: | |
//var str1ng='http://www.WHAK.com'; | |
//alert(myIndexOf(str1ng, 'WHAK')); | |
//-1 response means that it is not found in string | |
//returns character position that found is located |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minified: