简体   繁体   中英

dynamic virtual directories and external javascript links

hi I have a quick question.

i have a home.aspx and inside the page in the header I have a bunch of tags for external javascript files. My problem I am having is whenever a person adds a directory such as

http://localhost:444/differentnames/Home.aspx#

then the javascript links break and cannot be found. I've tried ../ but even that does not seem to work. Any suggestions or help would be appreciated.

try to load your references via the Pae_Init method.

It can be done with the Page.ClientScript.RegisterStartupScriptInclude() method.

http://msdn.microsoft.com/en-us/library/2552td66

Use ResolveClientUrl as so:

<head runat="server" id="head1"> <!-- runat="server" is important -->
  <script src='<%=ResolveClientUrl("~/scripts/jquery-1.4.1.js") %>' />

Where ~ is the App root directory. ResolveClientUrl will take care of resolving the path appropriately no matter how nested is the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM