|
-
Oct 9th, 2002, 11:31 AM
#1
Thread Starter
Frenzied Member
(Javascript) What is the equivilent to ASP's inStr in javascript?
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'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 9th, 2002, 12:26 PM
#2
Code:
function InstrThing(str,substr,start){
var oStr = new String(str);
return oStr.indexOf(substr,start);
}
indexOf returns position of substring in string or -1 if not found
-
Oct 9th, 2002, 02:01 PM
#3
Thread Starter
Frenzied Member
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:
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);
and the output:
4.0 (compatible; MSIE 5.5; Windows NT 4.0; T312461)
22
(compatible; MSIE
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...
and ideas?
Michael
Last edited by msimmons; Oct 9th, 2002 at 02:25 PM.
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 9th, 2002, 02:45 PM
#4
ahh if it's browser version you want
have a look at this
-
Oct 9th, 2002, 02:57 PM
#5
Thread Starter
Frenzied Member
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
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 9th, 2002, 03:10 PM
#6
Thread Starter
Frenzied Member
k here is what i did
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');
}
}
I know that is bad cos it only covers IE and will fail on the next vers of IE but this is only temporary 
thanks
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 10th, 2002, 03:17 AM
#7
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);
ok that link was me being lazy this will give you the version number.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|