Hi, I'm trying to write a simple function that will replace some text with an href link.
My current code only half works. The open tag "<a ..." is created ok, but the end tag "</a>" doesn't get created.
Does anyone know what I'm doing wrong?
My page has some user content with temporary tags that relate to external documents. I want the users to type in these tags rather than learn how to endit a proper href tag.
e.g. "{doc}547551{/doc}"
I have a basic Replace function which I call on the OnLoad event of the Body tag.
function ReplaceAll(searchText, replaceText) {
var intIndex = document.body.innerHTML.indexOf(searchText);
while (intIndex != -1) {
document.body.innerHTML = document.body.innerHTML.replace(searchText, replaceText);
intIndex = document.body.innerHTML.indexOf(searchText);
}
}
I call this function to replace the temporary tags using the following:
ret = ReplaceAll("{doc}", "<a href='OpenDocument.aspx?DocNumber='");
ret = ReplaceAll("{enddoc}", "'>link</a>");
When I change the replace text to use the bold tags "<b>...</b>" it seems to work fine. But the "<a>..</a>" tags don't work.
Any ideas are welcome.
My current code only half works. The open tag "<a ..." is created ok, but the end tag "</a>" doesn't get created.
Does anyone know what I'm doing wrong?
My page has some user content with temporary tags that relate to external documents. I want the users to type in these tags rather than learn how to endit a proper href tag.
e.g. "{doc}547551{/doc}"
I have a basic Replace function which I call on the OnLoad event of the Body tag.
function ReplaceAll(searchText, replaceText) {
var intIndex = document.body.innerHTML.indexOf(searchText);
while (intIndex != -1) {
document.body.innerHTML = document.body.innerHTML.replace(searchText, replaceText);
intIndex = document.body.innerHTML.indexOf(searchText);
}
}
I call this function to replace the temporary tags using the following:
ret = ReplaceAll("{doc}", "<a href='OpenDocument.aspx?DocNumber='");
ret = ReplaceAll("{enddoc}", "'>link</a>");
When I change the replace text to use the bold tags "<b>...</b>" it seems to work fine. But the "<a>..</a>" tags don't work.
Any ideas are welcome.