I know I have asked this before but I cannot find the post or where I used it in my code so....
What is the equivilent to ASP's inStr in javascript?
thanks
Michael
I know I have asked this before but I cannot find the post or where I used it in my code so....
What is the equivilent to ASP's inStr in javascript?
thanks
Michael
indexOf returns position of substring in string or -1 if not foundCode:function InstrThing(str,substr,start){
var oStr = new String(str);
return oStr.indexOf(substr,start);
}
Thanks. :)
I am trying to make a javascript redirect depening on IE version. I want it to go one way if 5.5+ and another way if 5.0- Here is what I have so far:
and the output:Code:document.write(navigator.appVersion + '<br><br>');
var intStart = (navigator.appVersion.indexOf('MSIE',1) + 5);
var intVers = navigator.appVersion.substring(parseInt(intStart), 3);
document.write(intStart + '<br>');
document.write(intVers);
so it is starting at the fourth position and giving me the next 22 chars... i want it to start at the 22position and give me the next 3 chars... so I flip it and it does the same...Quote:
4.0 (compatible; MSIE 5.5; Windows NT 4.0; T312461)
22
(compatible; MSIE
and ideas?
Michael
ahh if it's browser version you want
have a look at this
The problem with that script (besides being too dang long :) ) is that is only detects ie4+ or ie3- i need ie5.5+ ie ie5.0-
Michael
k here is what i did
I know that is bad cos it only covers IE and will fail on the next vers of IE but this is only temporary :)Code:var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer"){
if (navigator.appVersion.indexOf('MSIE 5.5',1)!=-1 || navigator.appVersion.indexOf('MSIE 6.0',1)!=-1){
alert('ok go to net');
}else{
alert('get a new browser');
}
}
thanks
Michael
ok that link was me being lazy this will give you the version number.Code:var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var fullVersion = parseFloat(nVer);
var majorVersion = parseInt(nVer);
// In Internet Explorer, the true version is after "MSIE"
if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
fullVersion = parseFloat(nAgt.substring(verOffset+5,nAgt.length));
majorVersion = parseInt(''+fullVersion);
}
// In Opera, the true version is after "Opera"
if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
fullVersion = parseFloat(nAgt.substring(verOffset+6,nAgt.length));
majorVersion = parseInt(''+fullVersion);
}
document.write('Full version = '+fullVersion+'<br>');
document.write('Major version = '+majorVersion);