Javascript replace string with chars

Hello,

I’ve been scouring for over an hour now and can’t find the answer anywhere.

what i want is i have a known url such as

http://www.example.com/webpage.php?var1=1&var2=234

which i have in an a tag object(obj.href)

data is then checked and upon success this link gets inserted to a database and the link is converted to another link

http://www.example2.com/webpage.php?var1=200&var2=87935

my problem now is using javascript to locate in a text version of the page(page source) the exact link “http://www.example.com/webpage.php?var1=1&var2=234” and replace all occurances with the new link.

i have tried a few different things but most of the things i find on this are about regexp converting any link

heres a simplified version of what im trying to do

<textarea id='textbox' style='height:50%;width:100%;'>http://www.example.com/webpage.php?var1=1&var2=234</textarea>
<div id='previewhtml'><a id='theObj' href='http://www.example.com/webpage.php?var1=1&var2=234'></a></div>
<a href='#' onclick="runReplace();return false;">run</a>
<script type='text/javascript'>
var theBox = document.getElementById('previewhtml');
var theCode = document.getElementById('textbox');
var obj = document.getElementById('theObj');
obj.responseText = 'http://www.example.com/webpage.php?var3=234&var4=variable';
//response from ajax
function runReplace(){
	theCode.value.replace(obj.href, obj.responseText);
}
</script>

im lost how to operate this replace function!