I am not sure if it does or does not. Some sites show using a contains in javascript but when I try it does not work.
I have
var userAgent = navigator.userAgent.split(';');
if (userAgent.contains("msie7") == true) {...}
I am trying to use the useragent to figure out if the user is running IE 8 in compatibility mode. So I want to check the userAgenet for msie7 & for the trident 4.0
So how could I check this array?
There is no native
Array.prototype.containsin ES v3 ( most JS implementations ). There is an Array.prototype.indexOf available in Mozilla/Firefox and other modern JS engines which choose to adopt it.You can use the code below to implement it on browsers/engines that dont have it: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/indexOf
Then after assigning it you can do
Array.prototype.contains = function(s) { return this.indexOf(s) !== -1 }