I’m loading a HTML fragment into a page using a jQuery AJAX call. The fragment is loaded from a separate directory on the server and I want to be able to reuse it (with its links to scripts and images) in different locations.
Is there a safe way using JavaScript/jQuery to translate all relative URL:s in a page – relative to where the HTML fragment was loaded from – before inserting it into the DOM?
If you wanted to modify the
hrefattribute of every link, you could do…