i’m creating a new dom element:
var bubbleDOM = document.createElement('div');
bubbleDOM.setAttribute('class', 'selection_bubble');
document.body.appendChild(bubbleDOM);
then i populate data to this DOM in a manner of text using .responseText with
XMLHttpRequest and finally change it’s css:
.selection_bubble {
position: absolute;
}
Everything works great until now. my problem is that a part of the data i’ve populated to
the DOM element has a href link such as:
/prop.php?id=333
which makes them think the link is really coming from my website, so when the user clicks on it he goes to:
http://www.mywebsite.com/prop.php?id=333
and i want those links to appear from the website (which i know it’s name and there is
only one i’m pulling the data from) as they should be:
http://www.thesitei‘mpullingfrom.com/prop.php?id=333
How can i change this either with CSS or JS?
To improve my original comment on the question:
In order to fix only the URLs that start with a slash (/), something like the following command should be run:
(edited in accordance with the comment fixing the expression)
responseText.replace(/(href=")(\/[^"]+)"/g, "$1http://thesiteimpullingfrom.com$2\"")