PHP & JavaScript Room :: 設置サンプル

実行結果

設置サンプル

【参照】jQuery Script to Automatically Preload images from CSS

設置サンプルのソース

<!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" xml:lang="ja" lang="ja">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="ja" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="imagetoolbar" content="no" />
      <title>設置サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <!-- JS -->
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript" src="/content/lib/jquery/preloadCssImages.jQuery_v4.js"></script>
      <script type="text/javascript">
         $(function(){
            $('#loadInfo').hide();
            $('button').click(function(){
               $('#loadInfo').slideDown();
               $(this).parent().after('<h2>Images loaded into DOM from CSS:</h2><ul id="loadedImgs"></ul>')
               var loadedImgs = $.preloadCssImages({statusTextEl: '#textStatus', statusBarEl: '#status'});
               for(var i = 0; i<loadedImgs.length; i++){
                  $('#loadedImgs').append('<li><img src=\"'+loadedImgs[i].src+'\" />: '+loadedImgs[i].src+'</li>');
               }
               //   $(window.parent.document).find('iframe:eq(0)').height('110em');
               return false;
            });
         });
      </script>
      <!-- CSS -->
      <link rel="stylesheet" type="text/css" href="css/layout.css" />
      <style type="text/css">
         body { text-align:left; margin:20px; background:none; }
         h1 { padding:0; }
         button { border:1px solid #333; -webkit-border-radius:5px; -moz-border-radius:5px; margin:10px 0; padding:5px 10px; color:#fff; font-weight:bold; background-color:#999; }
         /* status */
         #statusBar {border: 2px solid #aaa;width: 300px;background: #ddd url("/content/img/ajax/dadada_40x100_textures_06_inset_hard_95.png") 50% repeat-x;}
         #status {background: url("/content/img/ajax/f58705_40x100_textures_08_diagonals_thick_85.png") 0 50% no-repeat; height: 12px; }
         #textStatus {font-weight: bold; }
         #textStatus  .numLoaded {font-weight: bold;}
         #textStatus .numTotal {font-weight: bold;}
         #textStatus .percentLoaded {font-weight: bold;}
         #textStatus .currentImg {font-weight: bold; display: block;font-size: .8em;}
         #textStatus .currentImg span {font-weight: normal;  }
      </style>
   <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
   <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1>設置サンプル</h1>
         <p>【参照】<a href='http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/'>jQuery Script to Automatically Preload images from CSS</a></p>
<!-- CODE -->
         <div id="loadInfo"> 
            <p id="textStatus"></p> 
            <div id="statusBar"><div id="status"></div></div> 
         </div>
         <p><button>画像をプレロードする</button></p>
<!-- / CODE -->
      </div>
   </body>
</html>