Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  141] [ 3]  / answers: 1 / hits: 21748  / 7 Years ago, thu, june 1, 2017, 12:00:00

I am working on a function which looks through a list of table values on the page and if the column title contains any part of the output, it will convert the value accordingly.



function createLink(field, val) {

var output = {
'ntid': 'https://internal/profile/' + val,
'email': 'mailTo:' + val
};

var i, key, keys = Object.keys(output);
for ( i = 0; i < keys.length; ++i ) {
key = keys[i];
if ((field.toLowerCase()).includes(key)) {
return '<a href='+output[key]+' target=_blank>'+val+'</a>';
}
}

return val;
}


The issue I am running into is that IE is throwing an error on the .includes() line stating that Object doesn't support property or method 'includes'.



I had a bit of trouble getting it to work as is but didn't realize includes() must be something that not all browsers support.



Is there something else I can use in place of this that will allow for cross browser support ?


More From » javascript

 Answers
9

includes is part of the ECMAScript 2016 specification, so it's not supported in IE. What you can use instead is .indexOf(element) !== -1


[#57586] Wednesday, May 31, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cristinadomoniquel

Total Points: 320
Total Questions: 94
Total Answers: 94

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
cristinadomoniquel questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Tue, Dec 1, 20, 00:00, 4 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
Mon, Aug 17, 20, 00:00, 4 Years ago
;