...

View Full Version : Javascript image issue



tribalmp
10-09-2008, 11:13 AM
Hi,

How is possible to show an image without using document.write

document.write('<img src="image.jpg" border="0">')

Thanks for all the help provided

abduraooft
10-09-2008, 11:33 AM
OMG! Guess you've tried to learn javascript before HTML.
See http://www.w3schools.com/tags/tag_IMG.asp especially the "Try-It-Yourself Demos"

tribalmp
10-09-2008, 03:09 PM
Hi,

Your anwser is a little bit absurd, are you trying to pass me as a child or you are unable to answer???

Nevertheless here is a snip of the actual code.

<SCRIPT LANGUAGE="JavaScript">
function imageError() {
alert("This message will show if the image didnt load")
}
</script>

<img src="images/fail.jpg" border=0 onError="imageError(this)" onAbort="imageError(this)">

-----------------------------------------------
And i changed to this in hope to load a second image
-----------------------------------------------

<SCRIPT LANGUAGE="JavaScript">
function imageError() {
document.write('<img src="image/ok.jpg" border="0">')
}
</script>

<img src="images/fail.jpg" border=0 onError="imageError(this)" onAbort="imageError(this)">

But, the problem is that the image loads in a new layer, cleanning all the text, css, etc


OMG! Guess you've tried to learn javascript before HTML.
See http://www.w3schools.com/tags/tag_IMG.asp especially the "Try-It-Yourself Demos"

abduraooft
10-09-2008, 03:31 PM
No, I'm not a psychic, and I can't correctly guess what you have at your end or what you've tried so far. Please check the Posting Guidelines (http://www.codingforums.com/postguide.htm), especially the third one.

Yes, there are proper DOM methods like createElement() and appendChild() to add a new element to a document, but I'm afraid that your question is still not adequate to give a proper answer.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum