Forum Moderators: open

Message Too Old, No Replies

Path to Javascript above root

         

twave

3:18 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



I have a javascript that is created by a macro in an excel spreadsheet. For security it is created above my web root in /inetpub/js.

This is the script:

function
aWrite()
{
document.write('<p>Display this text</p>')
}

I want to call this script from an HTML page but cannot work out the path. The drive name is i: so I would assume this would work:

<script type="text/javascript" src="i://inetpub/js/awrite.js"></script>

Can anyone tell me what I'm doing wrong?

Bernard Marx

3:49 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you could access files above root from your webpages on the client side, then so could everyone else. I'm afraid your security also applies to your links.

[webmasterworld.com...]

bedlam

4:01 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you're doing wrong is trying to access a script that's not public. Javascript runs in the client (i.e. the browser), and must be downloaded to the browser before the browser can execute it. If it's in a directory above the web root (www, public_html, wwwroot etc), it's not going to be downloadable, and so it's not going to work.

There isn't any good way that I know of to keep javascript private. If you really want/need to protect your application's logic, you're likely going to need to go with a server-side language.

-b