Salve a tutti sto smanettando un po con javascript e facendo delle prove mi sono accorto che il mio script non accede agli elementi contenuti nel <body>, ma solo a quelli contenuti in <head> è mai possibile?
Vi posto il code :
File index.php
codice:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Ajax</title>
<script type="text/javascript" src="javascript/ajax.js"></script>
<script type="text/javascript" src="javascript/squadre.js"></script>
</head>
<body>
<h1>Lista delle squadre</h1>
Squadre</p>
</body>
</html>
file squadre.js
codice:
var tag = document.getElementsByTagName("*");
for(var i = 0; i < tag.length; i++){
alert(tag[i].nodeName);
}
Se lo eseguite stampa :
HTML
HEAD
META
TITLE
SCRIPT
SCRIPT
é allucinante!!!!!!
Perchè non stampa anche BODY H1 P A ?????