PDA

View Full Version : Disabling all elements


llp00na
04-28-2006, 07:23 AM
i am trying to disable all elements of a web page. Can someone please tell me which function is used to do that. in the underneath example getElementsByTagName("a") allows you to disable links only. I tried looking at the documentation but couldnt find which method enables you to disable all elements.

<script type="text/javascript">
function disableLinks()
{
var items = document.getElementsByTagName("a");
for(var i = 0; i < items.length; i++){
items[i].onclick = function(){
return false;
}
}
}
onload = disableLinks;
</script>

Thank you

llp00na
04-28-2006, 07:47 AM
Although i have never used javascript before, here what i tried to do. But its not working. Javascript experts please correct me

<script type="text/javascript">
function disableLinks()
{
var bodyElement = document.body;
traverseTree(bodyElement);
}
onload = disableLinks;
</script>

<script>
function traverseTree(n) {

var children = n.childNodes;
for(var i=0; i < children.length; i++) {
traverseTree(children[i]) ;

children[i].onclick = function()
{
return false;
}

}
</script>