By "total amount of nodes," do you mean *all* nodes (attribute notes, comments, etc.), or do you really mean "total amount of elements," or something different?
Also, out of curiosity: what is the purpose of finding the number of nodes in the document?
You can get all element nodes via document.getElementsByTagName("*"). If you want all nodes, a DOM2 NodeIterator is what you'd want to use ideally, though no browser supports it. A recursive call pushing nodes onto a stack would achieve the same thing though.