I have had similar problems loading images using relative URLs, though not quite the same situation.
I am using file-relative URLs (no leading /) because the site I am working on needs to work both as a website and in a PhoneGap app. I imagine this is a pretty common scenario for JQM sites. Normally, I would use site root-relative URLs. (Leading /)
Chrome (or JQM on Chrome) seems to get confused when referencing the same image file from different locations in the heirarchy that resolve to the same location.
Layout:
/
/todo.html /map/ /map/index.html /map/images/ /map/images/pin.pngNow, reference
pin-png from both
todo.html (
map/images/pin.png) and
/map/index.html (
images/pin.png).
Navigate from
todo.html to
map/index.html, then back again.
I should mention that part of the the todo page is re-generated dynamically on
pagebeforeshow. This includes the part that references the image. So, when one navigates "back" it is being re-generated. Normally, when navigating back a single level, one would not expect the page to be reloaded by JQM. So, a bit of a special situation.
Works fine with Safari.
With Chrome, the image appears correctly on the todo page on the initial load, as well as on the map page.
When you navigate back to the todo page, though, the image is not loaded.Chrome error log reveals that
it is incorrectly looking for the image in images/pin.png, but it should be loading from map/images/pin.png.
I solved this by adding a
<base> tag to the headers. It was not necessary to switch to using site root-relative URLS. (i.e. leading /)
I have also seen similar issues occurring after doing a page reload on a page below the root level of the site.
This is odd, given that JQM already actively manages the
<base> tag. If you do not supply a
<base>, JQM generates one, but if you supply one JQM will honor it. JQM also re-writes your URLs on platforms that don't properly handle the
<base> tag.
There is an Issue for JQM 1.2 (which is what I am using) not honoring a developer-supplied base tag, but it seems erroneous, since, at least in my case, JQM clearly
is honoring my
<base> tag:
https://github.com/jquery/jquery-mobile/issues/5083