動的に生成した HTML 要素に Flash タグを貼り付けると ExternalInterface が動作しない場合がある


ExternalInterface でハマった。

var hoge = document.createElement("hoge");
hoge.innerHTML = "<object...";
foo.insertBefore(hoge, foo.firstChild);

要素を動的に作ってすぐに innerHTML に Flash のタグを書き込み、その要素を別の要素に挿入した場合、IE だと Flash のメソッドを呼べない (undefined になる)。

var hoge = document.createElement("hoge");
foo.insertBefore(hoge, foo.firstChild);
hoge.innerHTML = "<object...";

なら OK。

ExternalInterface でハマらないためのリンク集

カテゴリー: Flash, JavaScript   パーマリンク

コメントをどうぞ

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>