Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    46
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Arrow Javascript image issue

    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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Oct 2008
    Posts
    46
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Arrow

    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

    Quote Originally Posted by abduraooft View Post
    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"

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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, 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.
    Last edited by abduraooft; 10-09-2008 at 03:35 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •