Count images in a document
<html> <body> <img border="0" src="http://www.java2s.com/style/logo.png" width="48" height="48"> <br> <img border="0" src="http://www.java2s.com/style/logoRed.png" width="107" height="98"> <p> <script type="text/javascript"> document.write("This document contains: " + document.images.length + " images.") </script> </p> </body> </html>