Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Ajaxulation question

Reply
Thread Tools

Ajaxulation question

 
 
Mr. SweatyFinger
Guest
Posts: n/a
 
      01-22-2007
I want use ajax. I want to swap out my images smoothly without getting stuck
between pages.
Do I need to add ajaxulate on each picture, or ajaxulate on the whole
website?


 
Reply With Quote
 
 
 
 
Laurent Bugnion [MVP]
Guest
Posts: n/a
 
      01-22-2007
Hi,

Mr. SweatyFinger wrote:
> I want use ajax. I want to swap out my images smoothly without getting stuck
> between pages.
> Do I need to add ajaxulate on each picture, or ajaxulate on the whole
> website?


Images do not need AJAX to get loaded or changed smoothly. With
JavaScript, setting the "src" property of the Image object is sufficient
to create a new HTTP Request for the image. In older browsers (Netscape
4), the image was sometimes not resized properly, but the new browsers
handle this without problems.

for example:

<img id="myImage" src="image1.jpg" alt="An image" />

var nImage = document.getElementById( "myImage" );
nImage.src = "image2.jpg";

If you additionally want the image to be "swapped" without any delay,
you can preload the image in the cache first. For example:

var cachedImage = new Image();

function swapImage()
{
var nImage = document.getElementById( "myImage" );
nImage.src = cachedImage.src;
}

cachedImage.onload = swapImage;
cachedImage.src = "image2.jpg";

With this code, the Http request is sent, the image sent back to the
browser. When the image is fully loaded, the onload event is fired, and
the image is swapped. Since the image is already in the browser's cache,
the swap is immediate.

No AJAX involved.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Premature AJAXulation Lawrence D'Oliveiro NZ Computing 2 04-16-2008 06:51 AM
I have an ajaxulation problem Mr. SweatyFinger ASP .Net 1 01-26-2007 07:45 PM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments