1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
<title>Test Preload</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
</style>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
var Test = {
preload: function(img) {
var imgLoad = [];
for (i=0; i<img.length; i++) {
imgLoad[i] = new Image();
imgLoad[i].src = img[i];
Test.waitload(imgLoad[i]);
}
return imgLoad;
},
waitload: function(obj) {
var tmp = setInterval(function() {
if(typeof obj=="object") {if(obj.complete) clearInterval(tmp);}
},1)
},
regexp: /([:\/\w]*index\.php\?p=)(\w)/gi,
click: function(e) {
$(e).click(function() {
var content = $(this).attr("href").replace(Test.regexp, "$2");
if ($(this).attr("target")==undefined) {
$("#content > div").fadeOut("fast", function() {
$("#content > div").load(content +".html #"+ content, function() {
$("#content > div").fadeIn("slow");
});
});
return false;
}
});
}
}
jQuery(function($) {
var imgLoad = Test.preload(['img/fond.jpg'] );
Test.click("a");
});
//-->
</script>
</head>
<body>
<div id="container">
<a href="index.php?p=content2" title="to content 2">to content 2</a></li>
<div id="content">
<div id="contentintro">
<p>content 1</p>
</div>
</div>
</div>
</body>
</html> |
Partager