swfobject
swfobject で swf を埋め込む
何故、embed ではなく javascript を使うのか?
- Flashプラグインがインストールされてない場合の表示が簡単にできる。
- FlashPlayerのバージョンが検出できる。
- swfファイルのwidth、height、background color(透明指定も可)などが制御できる。
ref:
絵心 - ひとりごと日記 - : SWFObject
実践
javascript:
<script src="js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"> var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699"); so.write("flashcontent"); </script>
var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
- movie.swf - 埋め込みたい swf のファイル名
- mymovie - swf に付ける id (あまり気にしなくて良いかな)
- 400 - swf の横幅 width
- 200 - swf の縦幅 height
- 8 - ユーザーがこれ以上のVersionのFlashPlayerの場合にswfを表示
- #336699 - 背景色の指定
so.write("flashcontent");
- idが「flashcontent」の場所にswfを埋め込みする
html:
<div id="flashcontent"> This text is replaced by the Flash movie. </div>
これで、FlashPlayer の Version8 より低い場合はswfが表示されず「This text is replaced by the Flash movie.」が表示されます。便利!
ref:
swfファイルを簡単に埋め込めるswfobject.js | CSS Lecture
ps: 食堂に導入された機械が紹介されてる。
[diary] 食堂で pittmo 発見 horiday blog