Object要素のイベントを拾う
swfを貼り付けるときに使用するobject要素、embed要素にonclickなどをいろいろ設定してみました。
結果
- IE6:object要素のonmouseout,onmouseover,onmousemoveは反応する。
- Firefox2:swfの隅のほうでobject要素のマウス系イベント(onclick,onmouseout ..etc)が反応する。swf上では反応しません。
ソース:
<?xml version="1.0" encoding="UTF-8"?> <!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" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <!-- object と embed にイベントハンドラを設定。 --> <object id='sample' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' onclick="out('object click')" onmousedown="out('object mouse down')" onmousemove="out('object mouse move')" onmouseup="out('object mouse up')" onmouseout="out('object mouse out')" onmouseover="out('object mouse over')" onkeydown="out('object key down')" onkeypress="out('object key press')" onkeyup="out('object key up')" > <param name='src' value='sample'/> <embed name='sample' src="sample.swf"' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' height='200' width='250' onclick="out('embed click')" onmousedown="out('embed mouse down')" onmousemove="out('embed mouse move')" onmouseup="out('embed mouse up')" onmouseout="out('embed mouse out')" onmouseover="out('embed mouse over')" onkeydown="out('embed key down')" onkeypress="out('embed key press')" onkeyup="out('embed key up')" > </object> <div id="stdout"></div> <script> var stdout = document.getElementById( "stdout" ); function out( str ) { stdout.innerHTML += str + "<br/>"; } </script> </body> </html>