473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 6219
unfortunatly iis does not support the "~" path specification (which is
really a unix feature). asp.net sorta supports it. when a server side
control renders a url it translates the "~" path to the vdir path.

to do this in javascript you can use a relative path:

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

which will work if the current page is in the basedir. if its in a
subfolder you can navigate up "../Scorecard Previews".

to a browser "/path", means server/path.

-- bruce (sqlwork.com)

Radu wrote:
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 #2
On Feb 9, 11:45 am, bruce barker <nos...@nospam.comwrote:
unfortunatly iis does not support the "~" path specification (which is
really a unix feature). asp.net sorta supports it. when a server side
control renders a url it translates the "~" path to the vdir path.

to do this in javascript you can use a relative path:

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

which will work if the current page is in the basedir. if its in a
subfolder you can navigate up "../Scorecard Previews".

to a browser "/path", means server/path.

-- bruce (sqlwork.com)

Radu wrote:
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- Hide quoted text -

- Show quoted text -
Thank you, Bruce, it worked :-))) Have a great weekend !

Feb 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joe Cybernet | last post by:
Is there any function for combining an absolute and a relative URL to result in an absolute URL? Like if I have http://www.domain.com and "../images/1.jpeg" it will evaluate to...
3
by: Peter Taurins | last post by:
Hi there. I have an included file (header.php) that contanis a reference to a graphic. If I stay at the root level, then I can control the relative path of the image. eg. images/imagename.jpg ...
1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
7
by: Rizaan Jappie | last post by:
is it possible to get the relative path based on a absolute path in c#? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
6
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data...
8
by: Daniel Serrano | last post by:
Hi, is it possible to use a relative path in a Connection string to access an Access database in a stand alone visual basic desktop application. All the examples that I have seen have absolute...
8
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the...
2
by: Alex | last post by:
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...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.