views:

227

answers:

2

To refer to the root of a website in asp I use an ASP control (normal hyperlinks don't work!) and use the tide ~

However I am trying to achive the same with Jscript and it does not work.

I have set up a folder structure to better organise the files on my website. I have placed a Jscript file within the root of the folder structure and refer to it like this

"/superslight.js" this is in the master page

The user navigates to a page that is one folder down the link breaks down becuase it's not looking at the root of the site but the root of the current folder

Any ideas?

+4  A: 

<script src="<%=ResolveClientUrl("~/superslight.js")%>"></script>

erikkallen
A: 

use two dots to refer to the parent folder :
assuming that you have the following folders structure

root---->pages---->myFile.aspx
root---->scripts---->myScript.js

you refer to myScript.js in myFile.aspx like this:

<script type="text/javascript" src="../scripts/myScript.js" />
Marwan Aouida