Home
Home Page
Algorithm of calculation PageRank
Complex Denwer: Apache+PHP+MySQL+Perl for 5 minutes
Protection against automatic registration by means of a picture
PageRank from Google
Effect of smooth transition on JavaScript
Some criteria of a choice of a hosting
Definition of the size of the removed file
Loading of files on FTP
Preloading of pictures
Animation underlining
Kiberskvoting and kiberskvotery
Third type XSS: Mezhsajtovyj skripting through DOM
IPv6: expansion of report IP
Job with SQLite
Transformation of hyperlinks by means of Apache server
Animation Favicon
All about meta tegakh
Beautiful code on PHP
Links
 

Preloading of pictures

Sometimes, during development of a site, there is a situation when it is necessary to use some images on page which poocheredi replace each other, thus the page is not updated. For this purpose preloading of images which allows is used will be loaded to images right at the beginning of the body text of page.


Actually, preloading is carried out surprisingly simply. Right at the beginning of page the small script is inserted:



<script language=JavaScript>

pic = new Image ();

pic.src = "test.jpg";

</script>


Where test-jpg - a preloaded picture which is not displayed on page, but at any moment of her{it} it is possible to display without additional expectation of loading of the image.


I shall result enough a simple example, that you would understand, what for in general it is necessary to use preloading of images:



<script language=JavaScript>

pic = new Image ();

pic.src = "sea_2.jpg";

</script>


<img src = "sea_1.jpg" style ='cursor: hand ' onclick ='this.src=pic.src '>

<img src = "sea_1.jpg" style ='cursor: hand ' onclick ='this.src = "sea_3.jpg" '>


Images sea_2.jpg and sea_3.jpg are absolutely identical, but the image sea_2.jpg is already stored{kept} in a variable pic.


By pressing the first picture, other picture will be displayed instantly as she it is already loaded, by pressing the second - it is necessary to wait for some time while she it will be loaded