0

I wrote a short code for a simplified HTML table, which contains a section for the first and lastname. In the last section is an automatically created link, which refers to a facebook account.

I want to retrieve the HTTP status code of these links, check if it is 404 and if it is, replace the checkmark with a red cross.

Currently I tried analyzing other pages JQuery code (like those for download websites), without success. I also did some research, but most of the content refers to already loaded elements such as pictures.

How can I replace the haken.gif with a cross.png, if http://facebook.com/Jill-Smith/ has a 404 error in its header?

I would appreciate your help for this example, since I'm a Javascript beginner and want to learn from your answers.

tr {
background:yellow;
}
<html>

<head></head>

<body>
 <table class="example">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>URL available</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td><a href="http://example.com/Jill-Smith/"><img src="http://www.gerso-shop.de/templates/8w_sunrise/img/haken.gif"/></a></td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td><a href="http://example.com/Eve-Jackson/"><img src="http://www.gerso-shop.de/templates/8w_sunrise/img/haken.gif"/></a></td>
  </tr>
</table> 
</body>

</html>
Otaku Kyon
  • 415
  • 1
  • 9
  • 19
  • you can't do this using javascript in browser if page is not on facebook.com. You would need to write server code to check them and communicate with your server code but chances are facebook will redirect you doing that also – charlietfl Oct 11 '16 at 22:01
  • @charlietfl My pity.. In case the table is on example.com and has a link to wiki.example.com, this should work, shouldn't it? I already came accross these answers before and had huge difficulties to understand this, since I'm a beginner. I really hoped that I could get some help to my needs.. – Otaku Kyon Oct 11 '16 at 22:03

0 Answers0