Hello everybody, I found only
one other person reporting this issue
here.
I have an html document with relative paths in it. To ease some work I append a base tag as a first child in the head of the document using this script where prd-ita is the folder containing all the website files:
here = window.location.href;
hereIndex = here.indexOf('prd-ita');
newPathname = here.substring(0, hereIndex+8);
$( "head" ).prepend('<base id="host" href="' + newPathname + '"/>');
This way all the relative paths acts like if the "newPathname" (eg. http://maxiride.it/bla/bla/
prd-ita or file:///D:/myUser/folder1/
prd-ita) is the prefix for all relative paths.
This method works properly and my content is properly loaded executed and shown. However every resource is loaded twice, once with the newPathname as a prefix (and this is correct) and another time with the real relative path (giving of course a 404 error) like if the base tag was absent.
Using Chrome inspect element I saw that in the loading order the browser first attempt was to load the resources from their relative paths, and only after it loaded them considering the base tag.
I tried to place the script inline directly inside the head tags hoping it would be executed for first, then I tried the
this script from the guy mentioned in the first line, I tried different "injections" method to add the vase tag (as you can see from the commented lines)