clubzone
asked on
Textarea HTML Editor tool - URL path file://
The below code has something to do with it....the html editor that I am using, if you enter a http URL, no problem it works. But for some reason if I enter an internal URL like this: file://H:\folder name
I always get the result as: "file:///H:/folder name" no matter what, it keeps adding an extra forward slash " / " in front of the file://. Is there anything wrong with the regular expression below? file:/// does not work, in outlook the file link works only with 2 slash file://H:/
try the demo here you'll see: http://www.openwebware.com/wysiwyg/demo.shtml
I always get the result as: "file:///H:/folder name" no matter what, it keeps adding an extra forward slash " / " in front of the file://. Is there anything wrong with the regular expression below? file:/// does not work, in outlook the file link works only with 2 slash file://H:/
try the demo here you'll see: http://www.openwebware.com/wysiwyg/demo.shtml
getDocumentPathOfUrl: function(url) {
var path = null;
// if local file system, convert local url into web url
url = url.replace(/file:\/\//gi, "file://");
url = url.replace(/\\/gi, "\/");
var pos = url.lastIndexOf("/");
if(pos != -1) {
path = url.substring(0, pos + 1);
}
return path;
},
/**
* Get the documents url, convert local urls to web urls
*
* @param {DOMElement} doc Document which is used to get the url
*/
getDocumentUrl: function(doc) {
// if local file system, convert local url into web url
var url = doc.URL;
url = url.replace(/file:\/\//gi, "file://");
url = url.replace(/\//gi, "/");
return url;
},
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What o/s and browser are you targeting (for the client not the web server)?
ASKER
windows XP Pro and IE6.0
ASKER
well it seems to work now! the server has to match exactly. the lower and upper case made the difference. if I were to type in file:///h:/intranet instead of file:///H:/INTRANET it would not work, if you match it exactly it works, I did not know lower uppercase made the difference? strange.
ASKER
Thanks for the link.
ASKER
even if I enter 2 // instead of 3 manually, it automatically puts it back to 3 slashes, why is it doing this, and how to fix it for my behalf.