troubleshooting Question

Textarea HTML Editor tool - URL path file://

Avatar of clubzone
clubzone asked on
Web Languages and StandardsJScript
6 Comments1 Solution386 ViewsLast Modified:
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;
	},
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros