473,785 Members | 3,417 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\Orderin g Process\Scoreca rd 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.d oc

(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.d oc

which is not correct - it should be

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

(I have an extra "~" character).

How should I set the path in JavaScript ?

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

cmdOpenScorecar dPreview.Naviga teUrl = "~/Scorecard
Previews/" & strSelectedScor ecard
Thanks a lot
Alex

Feb 9 '07 #1
2 6241
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="Sco recard 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\Orderin g Process\Scoreca rd 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.d oc

(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.d oc

which is not correct - it should be

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

(I have an extra "~" character).

How should I set the path in JavaScript ?

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

cmdOpenScorecar dPreview.Naviga teUrl = "~/Scorecard
Previews/" & strSelectedScor ecard
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="Sco recard 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\Orderin g Process\Scoreca rd 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.d oc
(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.d oc
which is not correct - it should be
http://localhost:1218/Ordering%20Process/Scorecard
%20Previews/MyScorecard_1.d oc
(I have an extra "~" character).
How should I set the path in JavaScript ?
In VB.net (code behind) it has been very simple:
cmdOpenScorecar dPreview.Naviga teUrl = "~/Scorecard
Previews/" & strSelectedScor ecard
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
9151
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 http://www.domain.com/images/1.jpeg. I know WinInet for windows has a function that does this called InternetCombineUrl, I just need the same function in PHP
3
3145
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 However, if I include this file (header.php) in a lower level directory then of course, I end up with no image displaying as the relative path is no longer correct.
1
4333
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 want to make first text as Table Heading/menu category. For examle in the given menu i want to make a heading as "Comp. Languages" which won't be a link. 2) The position of this menu is absolute to the page. I want to make it absolute to the Table...
7
78647
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
11789
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 source=c:/Inetpub/MyApp/data/database.mdb" /> ...
8
3455
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 paths but my application could be a lot more flexible if it didn't depend on this. Thanks, Daniel Serrano
8
2604
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 path can take the form of the following: 1. /directory/images/xyz.gif (works fine) 2. http://localhost:1234/www.mytestwebsite.com/directory/images/xyz.gif (doesn't work) 3. http:///www.someremotesite.com/directory/images/abc.gif (doesn't work)
2
7530
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 which changes the href of an <a>
15
6471
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 make it much easier to slap modualar blocks of markup into page frameworks, which may change and so forth. And the few extra bytes, which even for a fairly large site would not amount to as many bytes as are in a fairly small low-res image, should...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.