document.getElementsByTagName(\"*\")
works for IE/Firefox/Opera, But doesn\'t work for Chrome and Safari.
document.all
works for IE/Chrom/S
Without sufficient rep to comment on @Khurram Hassan 's answer, I'll put it here, along with my answer to the original question.
First, the original question. My solution would be (and is in my own code, pending an answer to a problem with it which I put up on this site) document.getElementsByTagName("*"), which actually does get every single element on Chrome. I tested it out on google.com on Google Chrome with a profile loaded and the eight most common visited sites listed, and it came out to 356 individual elements with a tag name. In fairness, this included html, head, body, and others that probably aren't useful, but it still got them. I don't have access to Opera at the moment, but with Chrome still accepting that piece of JavaScript, I don't see a reason why it wouldn't accept that in your code.
Second, for @Khurram hassan, document.getElementById()
can't be used in this case. I just tested it on Chrome, and it came up with a value of null. In theory, anything with the general form of getElementsBy*
as opposed to getElementBy*
could probably be used in this case. So, to add to my earlier answer, you might also try ClassName
, Name
, and TagNameNS
depending on what you're trying to do. On the same page as before, I tested those three and while only TagNameNS
worked, the rest just returned empty lists, not errors.
Further, if it is true that you don't need in your code, perhaps you could post the working code as an edit to your answer so that we can see it.
seems, to the best of my knowledge, to be the commonly accepted (and usually assumed to be mandatory) way of starting an HTML page. If it's not necessary, then that would be new information (at least to me) that could prove useful in either debugging or non-public webpages down the road.