"Goran Petrovic" <st*********@email.htnet.hr> writes:
I wrote a vb function, but i need it i jaavscript..i know java sintax but am
It will help you slightly, but Javascript is not Java. Their syntaxes
are similar, but not equal.
not sure how to make it work. this extracts teh file name from a path...i
thought strcpy..or something..but dont really know. Please help
if mid(str,i,1)="/" then
str= mid( mid(str,i+1,100),1,len( mid(str,i+1,100))-4)
str="../../../aspx/quotes"+str+".aspx"
GetWriterName="../../../aspx/quotes"+str
Do you really mean this? The result will be
"../../../aspx/quotes../../../aspx/quotes"+filename+".aspx;
I don't even think there is a "/" in front of the filename.
I guess one of them are superflous.
A solution:
---
function getWriterName() {
var str = location.pathname; // easier than working with full href.
for (var i = str.length ; i > 0 ; i--) {
if (str.charAt(i)=="/") {
str = str.substring(i+1); // no second argument means until end of string
return "../../../aspx/quotes/"+str+".aspx";
}
}
}
---
Now for the easier way:
---
function getWriterName() {
var str = location.pathname;
var i = str.lastIndexOf("/");
return "../../../aspx/quotes"+str.substring(i)+".aspx";
}
---
Good luck.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'