
January 27th, 2013, 06:56 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 7
Time spent in forums: 1 h 51 m 27 sec
Reputation Power: 0
|
|
|
How to get the line number of image where alt/title is missing..??
Hi guys, i am having the javascript function uses regular expression which gives a list of images without alt/title attribute... is there any way to get the line number along with the images Quote: | Alt missing in line no:___ <img src="images/Demo.jpg" border="0"> |
My HTML will look like this...
Code:
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<table width="600" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width=""><img src="images/Demo.jpg" border="0"></td>
<td width=""><img src="images/Demo.jpg" border="0"></td>
</tr>
<tr>
<td width=""><img src="images/Demo.jpg" border="0"></td>
<td width=""><img src="images/Demo.jpg" border="0"></td>
</tr>
</table>
</body>
</html>
Below is the function
Code:
function AltTitle(aSourceHTML, aResultField) {
try {
regexp = /<img((?:(?!alt)[^<>])*)>/gim;
var vArray = aSourceHTML.match(regexp);
var vLinks = vArray.join("\n\n");
aResultField.value = vLinks;
} catch (err) {
alert("No Images Found");
}
}
This will return out put like this
Code:
<img src="images/Demo.jpg" border="0">
<img src="images/Demo.jpg" border="0">
<img src="images/Demo.jpg" border="0">
<img src="images/Demo.jpg" border="0">
How to get the line number of image where alt/title is missing..??
|