วิธีที่ 1:
การคัดลอกรหัสมีดังนี้:
<script type = "text/javascript">
var obj = ภาพใหม่ ();
obj.src = "yourpicurl.jpg";
obj.onload = function () {// สถานที่นี้สามารถเขียนได้ซ้ำ ๆ
document.getElementById ("mypic"). innerhtml = "<img src = '"+this.src+"' />";
-
</script>
<div id =” mypic”> onloading … </div>
วิธีที่ 2:
การคัดลอกรหัสมีดังนี้:
<script type = "text/javascript">
var obj = ภาพใหม่ ();
obj.src = "yourpicurl.jpg";
obj.onreadyStateChange = function () {
ถ้า (this.readyState == "เสร็จสมบูรณ์") {// สถานที่นี้สามารถเขียนได้ซ้ำ ๆ
document.getElementById ("mypic"). innerhtml = "<img src = '"+this.src+"' />";
-
-
</script>
<div id =” mypic”> onloading … </div>
วิธีที่ 3:
การคัดลอกรหัสมีดังนี้:
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<tite> เอกสารชื่อ UNT </title>
</head>
<script language = "javascript" src = "/js/jQuery-1.4.4.js" type = "text/javascript">
</script>
<script language = "javascript" type = "text/javascript">
<!-// var total; var curt = 0; $ (เอกสาร). พร้อม (ฟังก์ชั่น ()
-
total = $ ("#content img"). ความยาว;
$ ("#content img"). แต่ละ (ฟังก์ชั่น () {var image = new image ();
image.src = $ (นี่) .attr ('src');
if (image.complete) {
imageLoaded ();
-
อื่น{
image.onload = imageLoaded;
-
-
-
ฟังก์ชั่น imageLoaded () {
CURT+= 1;
if (curt == ทั้งหมด) {
$ ("#เนื้อหา"). show ();
-
</script>
</head>
<body>
<div id = "content" style = "display: none;"
<img src = "" />
<img src = "" />
<img src = "" />
</div>
</body>
</html>