View Full Version : Displaying a jpg file...

12-25-2005, 06:28 AM
Script: Dynamic Ajac Content

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!!


12-25-2005, 12:49 PM
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:

<script type="text/javascript">

function displayimage(url, container){
document.getElementById(container).innerHTML='<img src="'+url+'"/>'
return false


<div id="test">

<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. :)