|
| ||||||||||
| Tags: imgae count, javascript, jscript, programming language, scripting language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| JavaScript to count number of images
|
|
#2
| ||||
| ||||
| Re: JavaScript to count number of images Images Object Array is supported in JavaScript 1.1 version of JavaScript. The Image Object Array is a collection of all the images in a document. To determine the total number of images displayed in the document we need to use the length property. Thus if you need to count the number of images using JavaScript use the length property of Image Object Array. |
|
#3
| ||||
| ||||
| Image Object for Images
In JavaScript we can deal with images in a document using JavaScript Image Object. The basic syntax to access the image using the image object is: To access image relative to its location in an array: Quote:
Quote:
Quote:
|
|
#4
| ||||
| ||||
| document.images.length to count image
I too had to keep a track of the image count in my JScript project where the images resembled the choices made by the visitor and I had to tally them all at the end. I tried many things and finally this piece of code helped me to get the image count: Code: <script language="JavaScript1.1">
document.write(document.images.length);
</script> |
|
#5
| ||||
| ||||
| JavaScript for HTML Code: <html>
<B>Tiger</B>
<img src="Tiger.gif">
<br>
<B>Cat</B>
<img src="Cat.gif">
<br>
<B>Lion</B>
<img src="Lion.gif">
<br>
<script language="JavaScript">
<!--
document.write(document.images.length," Images");
-->
</script>
</html> |
|
#6
| ||||
| ||||
| counting images in JavaScript
I had an assignment question where in it was required to a count of images on a web page which was to be scripted using JavaScript. We were given two images on a document and had to count them to display the image count as 2. This is the program that I did: Code: <html>
<body>
<img alt="Virus" border="0" src="Pic1.gif" width="70" height="70" />
<br />
<img alt="Worm" border="0" src="Pic2.gif" width="50" height="50" />
<br /><br />
<script type="text/javascript">
document.write("The image count of this document is: " + document.images.length);
</script>
</body>
</html> |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "JavaScript to count number of images" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to count number of characters in Excel | Bankebihari | Windows Software | 6 | 15-05-2012 04:52 PM |
| PHP - Count number of words | GlassFish | Software Development | 3 | 27-11-2009 12:19 PM |
| Count the number of times yes appears in a range in excel | Andy Candy | Windows Software | 3 | 17-08-2009 12:33 PM |
| How to count number of words automatically? | Basaam | Windows Software | 4 | 25-04-2009 10:00 PM |
| How To Count The Number Of Characters? | Harsh01 | Software Development | 2 | 13-02-2009 11:25 AM |