How to show image before executing javascript?

JavaScript alternative to HTML tag?

  • Hello, So I have a website, lets call it site1.com, which is ALWAYS online. I also have another website (on a different server) that is only online part time, lets call it site2.com On site1.com, I want to load an image from site2.com. I'm currently using the standard HTML <img src="http://site2.com/image.png" alt="blah" />. The whole purpose of that image is to tell visitors on site1.com if the server at site2.com is online, and if it's not, it SHOULD show the alt text "blah". For the most part, this works in IE and FF, but not in chrome. In chrome I get chrome's standard 404 page in place of that image when the server is offline. What I want to do is write some JavaScript to put in place of the standard HTMl <img/> tag that will; 1. load (and display) the image from site2.com/image.png 2. if the image is not reachable, I want it to load an image from blah.com/external.png How would I go about doing this? Thankyou very much!

  • Answer:

    According to the first discussion below it seems that short alt strings might work. The second link eventually proposes a solution using javascript and jQuery.

Kohlby at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

According to the first discussion below it seems that short alt strings might work. The second link eventually proposes a solution using javascript and jQuery.

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.