function parReplace() {
var myPar = document.getElementById('scriptTest');
// delete all children
if (myPar.hasChildNodes()) {
while (myPar.childNodes.length >= 1) {
myPar.removeChild(myPar.firstChild);
}
}
// add new children
var stringOne = document.createTextNode('This paragraph content was generated by JavaScript. If you were viewing the ');
var anchorOne = document.createElement('a');
anchorOne.setAttribute('href','index.php');
var anchorText = document.createTextNode('index.php');
anchorOne.appendChild(anchorText);
var stringTwo = document.createTextNode(' version of this page, the script would have been deleted from the page source and thus would not have executed.');
myPar.appendChild(stringOne);
myPar.appendChild(anchorOne);
myPar.appendChild(stringTwo);
}
|