Link to home
Start Free TrialLog in
Avatar of clubzone
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
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;
	},

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of clubzone
clubzone

ASKER

The thing is I use this with my work Intranet server and 3 slashes does not work, people needs to link to Internal file server, therefore it has to be set to file://D:\folname\thisfile.xls

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.
What o/s and browser are you targeting (for the client not the web server)?
windows XP Pro and IE6.0
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.
Thanks for the link.