469,313 Members | 2,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

Relative & absolute path question (JavaScript, mostly)

Hi.

I have files in the "Scorecard Previews" subfolder of the virtual path
of my app,
the absolute path being

C:\Data\Ordering Process\Scorecard Previews\
I have a javascript function which changes the href of an <a>
depending on some selection in a combo. If in the javascript function
I set the href like this:

hLink.href="/Scorecard Previews/"+ cbo.options[index].text +
".doc"

the <apoints to something like

http://localhost:1218/Scorecard%20Pr...corecard_1.doc

which is not correct - it should be

http://localhost:1218/Ordering%20Process/Scorecard
%20Previews/MyScorecard_1.doc

(I'm missing part of the path) - the path to the application.
If i set the href like this:

hLink.href="~/Scorecard Previews/"+ cbo.options[index].text
+ ".doc"

the <apoints to something like

http://localhost:1218/Ordering%20Process/~/Scorecard
%20Previews/MyScorecard_1.doc

which is not correct - it should be

http://localhost:1218/Ordering%20Process/Scorecard
%20Previews/MyScorecard_1.doc

(I have an extra "~" character).

How should I set the path in JavaScript ?

In VB.net (code behind) it has been very simple:

cmdOpenScorecardPreview.NavigateUrl = "~/Scorecard
Previews/" & strSelectedScorecard
Thanks a lot
Alex

Feb 9 '07 #1
2 7389
VK
On Feb 9, 7:20 pm, "Alex" <cuca_macaii2...@yahoo.comwrote:
How should I set the path in JavaScript ?
Same way as everywhere else I guess. Either you have an absolute link
or relative link, in the latter case the relative links are resolved
into absolute ones either by the page URL or - if specified - by base
URL.

Give the exact URL of page where the dynamic link is located and the
exact URL you want to navigate to on click. This way the best solution
can be siggested.

Feb 9 '07 #2
On Feb 9, 12:41 pm, "VK" <schools_r...@yahoo.comwrote:
On Feb 9, 7:20 pm, "Alex" <cuca_macaii2...@yahoo.comwrote:
How should I set the path in JavaScript ?

Same way as everywhere else I guess. Either you have an absolute link
or relative link, in the latter case the relative links are resolved
into absolute ones either by the page URL or - if specified - by base
URL.

Give the exact URL of page where the dynamic link is located and the
exact URL you want to navigate to on click. This way the best solution
can be siggested.
Thanks a lot, VK, it worked ! :-))

Feb 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Joe Cybernet | last post: by
3 posts views Thread by Peter Taurins | last post: by
7 posts views Thread by Rizaan Jappie | last post: by
6 posts views Thread by openleren | last post: by
8 posts views Thread by Daniel Serrano | last post: by
8 posts views Thread by JJ | last post: by
15 posts views Thread by Lars Eighner | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.