rechy_k
06-29-2006, 04:39 PM
Hi there,
I am new here...I read all the guidelines, searched the forum, but still couldn't find an answer.
I want to do the following:
-Read the URL of the current file
-replace the file name with a new file name
-open the new file
(everything is running currently on my local machine, so it comes back as: file://C:Documents\new\file.html, and I want it to look like C://Documents/new/file2.html)
My problem:
-Reading the file, the path has "\".
-To open a file, the path needs to have these "/"
-I am trying to replace them with a while loop, but whenever I use "\" to split the string or give me the index of its position, I get an error for invalvid character
Here is the piece of code so far... not even mentioning that I want to replace the file name...
function findPath()
{
var page = document.URL;
page = page.split("//");
var fullpath = page[1];
fullpath = fullpath.toString();
alert (fullpath);
//var c = fullpath.charAt(2); -> this puts out the \ just fine
//var c = fullpath.indexOf(\); -> this gives me invalid character
//alert (c);
//abc = fullpath.split("\"); -> this solution I would prefer, but gives me
also an invalid character message
//var i = 2;
//path = fullpath[1];
//while (i < fullpath.length)
// {
// path = path.concat("/",fullpath[i]);
// }
}
I appreciate any help
rechy
I am new here...I read all the guidelines, searched the forum, but still couldn't find an answer.
I want to do the following:
-Read the URL of the current file
-replace the file name with a new file name
-open the new file
(everything is running currently on my local machine, so it comes back as: file://C:Documents\new\file.html, and I want it to look like C://Documents/new/file2.html)
My problem:
-Reading the file, the path has "\".
-To open a file, the path needs to have these "/"
-I am trying to replace them with a while loop, but whenever I use "\" to split the string or give me the index of its position, I get an error for invalvid character
Here is the piece of code so far... not even mentioning that I want to replace the file name...
function findPath()
{
var page = document.URL;
page = page.split("//");
var fullpath = page[1];
fullpath = fullpath.toString();
alert (fullpath);
//var c = fullpath.charAt(2); -> this puts out the \ just fine
//var c = fullpath.indexOf(\); -> this gives me invalid character
//alert (c);
//abc = fullpath.split("\"); -> this solution I would prefer, but gives me
also an invalid character message
//var i = 2;
//path = fullpath[1];
//while (i < fullpath.length)
// {
// path = path.concat("/",fullpath[i]);
// }
}
I appreciate any help
rechy