Results 1 to 2 of 2

Thread: Displaying a jpg file...

  1. #1
    Join Date
    Dec 2005
    Location
    Washington
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Displaying a jpg file...

    Script: Dynamic Ajac Content
    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    I would like to know if anyone knows how to display a .jpg file with this script - for example:

    <a href="javascript:ajaxpage('test.jpg', 'contentarea');">test</a>

    Rather then:

    <a href="javascript:ajaxpage('test.htm', 'contentarea');">test</a>

    So far I have not been able to make it work. Any help would be GREAT!!

    -Matt

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You don't need ajax to dynamically get and display an image, since Ajax is used to retrieve once impossible information that is an entire external page. So to answer your question:

    Code:
    <script type="text/javascript">
    
    function displayimage(url, container){
    document.getElementById(container).innerHTML='<img src="'+url+'"/>'
    return false
    }
    
    </script>
    
    <div id="test">
    </div>
    
    <a href="#" onClick="return displayimage('http://news.com.com/i/ne05/hdrs/newslogo_220x70.gif', 'test')">Show it</a>
    As you can see, no Ajax.

Bookmarks

Posting Permissions

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