Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2012, 03:27 AM   PM User | #1
jmcall10
New to the CF scene

 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jmcall10 is an unknown quantity at this point
Exclamation Javascript file referencing

Hi,

I believe this is a simple problem however I am not the best at javascript.

First of all I started with the following:
Code:
<a href="\\SERVER-01\folder\file.xls" target="_blank">
however this opens the XLS file in a web browser.

So I then created a function called "RunFile"

so when I do the following it works fine:

Code:
<a href="#" onclick="RunFile('G:/Server/folder/file.xls');">Click me</a>
However my problem is that the "G" drive is mapped. So when I try:
Code:
<a href="#" onclick="RunFile('\\SERVER-01\folder\file.xls');">Click me</a>
it does not work. There is nothing wrong with the mapping so I am assuming I must have to use the "file://" prefix in some manner? I have tried various alternative to no avail.

Regards,

jmcall10
jmcall10 is offline   Reply With Quote
Old 11-09-2012, 09:23 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
What code do you have in RunFile()
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 11-09-2012, 11:18 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,162
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
A backslash in a JavaScript string indicates that the next character designates some special meaning. e.g., \n means newline. \t means tab. And so on.

This is true EVEN IF the character after the backslash is NOT special: In that case, the backslash is just ignored.

So to actually *use* a backslash in a string, you must use TWO of them:
Code:
<a href="#" onclick="RunFile('\\\\SERVER-01\\folder\\file.xls');">Click me</a>
As it was, your code was giving RunFile the string "\SERVER-01folderfile.xls"
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:47 PM.


Advertisement
Log in to turn off these ads.