publicidadpixelada
Feb 11th 2007, 3:39 pm
Hey... Just a quick question regarding the replace method in javascript.
I have the following html document to replace an url (oldurl) for another url (newurl):
<a id="link" href="http://oldurl.com">Old Url</a>
<script type="text/javascript">
var oldurl = document.getElementById('link');
var newurl = oldurl.replace("http://oldurl.com", "http://newurl.com");
document.write('<iframe src="' + newurl + '" width="500" height="500"></iframe>');
</script>
But the script get stuck in the replace part and I keep getting the following error in Mozilla:
oldurl.replace is not a function
And in IE:
Object doesn't support this property or method
Any ideas? Please it's driving me crazy!
I have the following html document to replace an url (oldurl) for another url (newurl):
<a id="link" href="http://oldurl.com">Old Url</a>
<script type="text/javascript">
var oldurl = document.getElementById('link');
var newurl = oldurl.replace("http://oldurl.com", "http://newurl.com");
document.write('<iframe src="' + newurl + '" width="500" height="500"></iframe>');
</script>
But the script get stuck in the replace part and I keep getting the following error in Mozilla:
oldurl.replace is not a function
And in IE:
Object doesn't support this property or method
Any ideas? Please it's driving me crazy!