Questions | Login

Top / Javascript

How to replace text on page load in Javascript?

demo 20 Dec 2008 12:27pm
OK. So I have a code fragment as below...

<blockquote>&#3207;&#3238;&#3265; &#3240;</blockquote>

Now, I want the & symbol to be replaced with nothing, or in other words I want to delete the & word from that code chunk when the page loads. What is the Javascript that can help me do this?

Many thanks!

SK

Answers

demo 20 Dec 2008 12:39pm
<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function replace(){
document.
getElementById("replaceThisText").
firstChild.nodeValue = "";
}
</script>
</head>

<body onload="replace();">
<blockquote id="replaceThisText">&#3207;&#3238;&#3265; &#3240;</blockquote>
</body>
</html>

BIG NOTE:
function replace(){
document.
getElementById("replaceThisText").
firstChild.nodeValue = "";

should all be on one line. Yahoo Answers doesn't allow me to type the whole thing like that though :(

Hope that helps!

Related

Submit Answer

You must be logged in to post an answer. Please Login or Register.

Powered by phpMyAnswers.