Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6236955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:56:24+00:00 2026-05-24T10:56:24+00:00

We have multiple versions of our web app each running in their own virtual

  • 0

We have multiple versions of our web app each running in their own virtual folders off the root. On development machines, the app is running out of the root:

http://localhost/              
http://localhost/v1
http://localhost/v2

Each application has many folders and many pages. The images are all in an ~/images folder:

http://localhost/images/awesome.jpg
http://localhost/v1/images/awesome.jpg
http://localhost/v2/images/awesome.jpg

http://localhost/index.aspx
http://localhost/v1/index.aspx
http://localhost/v2/index.aspx

http://localhost/foo/warble.aspx
http://localhost/v1/foo/warble.aspx
http://localhost/v2/foo/warble.aspx

Now, in my javascript I need to refer to one of these images, but it needs to be in that version’s folder. I don’t necessarily know what page is using this Javascript. How can I insert a relative URL to an image? Sure, I could use something like ../../images/awesome.jpg, but that would only work for pages that are two folders removed from the root:

  • Will work for: http://localhost/v1/foo/bar/page.aspx
  • Will not work for: http://localhost/v1/foo/page.aspx

I can’t use an absolute path because of the versioning aspects of the app hosting. Any ideas how I can get past this most troublesome roadblock? I am tagging jQuery in case there’s some jQuery library function that can handle this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:56:27+00:00Added an answer on May 24, 2026 at 10:56 am

    You need to pass the images directory url to javascript from the server side code somewhere on each page you’ll need. Consider putting it inside the <head> element in the layout and before the javascript files that will be needing it.

    <script>
      var imagePath = '<%=Page.ResolveUrl("~/images/") %>';
    </script>
    

    and with MVC razor engine:

    <script>
      var imagePath = '@Url.Content("~/images/")';
    </script>
    

    And then use the global variable imagePath in your javascript files to link to your images:

    img.src = imagePath + 'image01.jpg';
    

    Another solution is to use CSS which can handle relative paths by linking to a CSS file in the images directory and using the images in javascript via CSS classes and ids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have multiple groups running their own TeamCity setups inside the firm. My group
We have multiple versions of our web services (both REST and SOAP) in production,
In our web application, we have multiple small applications availables. Let us say A,B,C.
I'd like to have multiple versions of an object with different access modifiers on
I have multiple Matlab versions installed on my PC. To say, R2006b, R2009b, R2010a.
I have noticed that sometimes people have to use multiple versions of jQuery in
If you install multiple versions of python (I currently have the default 2.5, installed
I have an application which supports multiple types and versions of some devices. It
We have multiple log files like database log, weblog, quartzlog in our application. Any
I have multiple DIVs containing an image in each. When I rollover these DIVs,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.