I'm trying to figure out how to resolve relatively referenced resources inside dynamically loaded content. For example, suppose I had the following page downloaded from /index.html
:
<html><body>
<div id="insert-here" />
<script>
$(function(){
$("#insert-here").load("x/ajax-content.html");
});
</script>
</body></html>
And ajax-content.html
contains:
<img href="foo.png"/>
Then foo.png
will be downloaded from /foo.png
, which is not what I want. I need the foo.png
to be downloaded relative to the HTML that referenced it, so I need it downloaded from /x/foo.png
. I'm wondering if there is a way to do this (aside from using an absolute path in ajax-content.html
)?
(Why would I want to do this? I am developing an AJAX-based plug-in architecture that allows blocks of page content to be developed and deployed independent of the application.)