By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,479 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

URL to link to a file

P: 7
I have some JS code that reads URLs file links from a database and creates link the the files on a web page. It works fine in IE 6 but now I want it to work in Firefox. The URLs I need to handle are:
file:\\Server\Share\Directory\File.ext
file:\\\\Server\Share\Directory\File.ext
file://Server/Share/Directory/File.ext

I have figured out if I use 5 backslashes it will work in both browsers. I am having problems replacing the slashes. I think they might be getting interpretded as escape characters. Does anybody have some code to make these links work in both browsers?

Thanks,
Paul
Jan 3 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Can you show the code that you're having problems with.
Jan 4 '08 #2

P: 7
Can you show the code that you're having problems with.
Here is the code.
Expand|Select|Wrap|Line Numbers
  1.     function fnNewWindow<%=lintGadgetID%>(lstrurl,ablnWindowStatus)
  2.     {
  3.         var lstrPageName;   //variable to hold Page name.
  4.         var lstrnewWind;      //variable to hold Window status.
  5.         lstrPageName = lstrurl;    
  6.  
  7.         if(lstrPageName.substring(0,3).toUpperCase()=="WWW")
  8.             lstrPageName = "http://"+lstrPageName;
  9.  
  10.         if    ((lstrPageName.substring(0,4).toUpperCase()!="HTTP")&&(lstrPageName.substring(0,4).toUpperCase()!="FILE"))
  11.             lstrPageName = "file:"+lstrPageName;
  12.         else if(lstrPageName.substring(0,4).toUpperCase()!="FILE")
  13.             lstrPageName = lstrPageName
  14.         if (ablnWindowStatus == 0)
  15.             document.location.href=lstrPageName;            
  16.         else
  17.             lstrWindowStatus = window.open(lstrPageName,"New_Win","width=640,height=480,left=120,top=30,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,directories=yes");
  18.  
  19.     }
  20.  
  21.  
Jan 4 '08 #3

acoder
Expert Mod 15k+
P: 16,027
The URL should use forward slashes - see this Mozillazine link.

One other thing: document.location.href should be window.location.href.
Jan 5 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.