Problem with image paths in Javascript files

Topics: ASP.NET 2.0, Themes
May 17, 2010 at 9:15 PM
Edited May 18, 2010 at 1:33 PM

Hey all, trying out Blogengine.net and I think I'm doing reasonably well for a first-timer.

But I'm having trouble with image paths in a javascipt. Hope someone can help.

I'm using a kind of preloader script that changes the src of an img on window.onload depending on some parameters (time, etc.). It works fine on the default.aspx page, but once I click on a blog entry the images don't load. It seems to be a path problem. Tried everything I could think of in the script (although I'm far from a Javascript expert), but I can't get it to work in both pages.

To make it simple, the following javascript will work on some, but not all pages, due to path problems:

var item1;
window.onload = function() {
     item1 = document.getElementById('IMG1');
     item1.setAttribute("src", "imgs/main.gif");
}

with "/imgs/main.gif" none of the pages load the images.
with "../imgs/main.gif" the pages that work just switch.

So I can't get them all to work.

Any help on what I'm doing wrong? Thanks !

EDIT: apparently this also has something to do with developing locally (VWD Express 2008).