By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

Relative & absolute path question (JavaScript, mostly)

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.