クロスブラウザでdocument.createElement(‘iframe’)した要素のonloadを呼び出す方法
…….φ(..)メモメモです。
document.createElement(‘iframe’) で作った DOM 要素に onload をセットする場合以下のようなコードを使います。
var iframe = document.createElement('iframe');
var onload_func = function() {
// onload で実行する処理
}
if (document.all && !window.opera) {
// IE の場合 onreadystatechange が必要
iframe.onreadystatechange = function() {
if (iframe.readyState == "complete") {
onload_func();
}
}
} else {
// IE 以外なら onload で良い
iframe.onload = function() {
onload_func();
}
}
iframe.src = '...';
parentNode.appendChild(iframe);
var onload_func = function() {
// onload で実行する処理
}
if (document.all && !window.opera) {
// IE の場合 onreadystatechange が必要
iframe.onreadystatechange = function() {
if (iframe.readyState == "complete") {
onload_func();
}
}
} else {
// IE 以外なら onload で良い
iframe.onload = function() {
onload_func();
}
}
iframe.src = '...';
parentNode.appendChild(iframe);
コメントにも書いてますが、IE8 以下の場合 onreadystatechange を使う必要があります。
お世話になります。とても良い記事ですね。
I see a lot of interesting content on your page.
You have to spend a lot of time writing, i know how to save
you a lot of work, there is a tool that creates readable, google friendly articles in couple of seconds, just type in google
- k2 unlimited content
I read a lot of interesting content here.
Probably you spend a lot of time writing,
i know how to save you a lot of work, there is an online tool that creates high quality, SEO friendly posts in seconds, just type in google – k2seotips unlimited content
WRLexGamIMeVJxhKFL 7297
I ɑm sure thiѕ paragraph hаs touched аll the internet viewers,
its really гeally fastidiopus paragraph оn building սp neew web site.
Silahkan Cek hawlaman website Ane hanya untuk mendapat
Dataa lebih keren tentang agen bola Sbobet terpercaya .
Terma Kasih
Helllo to aⅼl, thе contentss ⲣresent at thiѕ site aree really amazing ffor people knowledge, ᴡell, ҝeep
uρ tһe gоod ѡork fellows.
Jangan sungkan untuk mengunjungi sute Saya hanya untuk dapatkan Informasi lebih keren mengenai
pusat cetak kaos murah .
Suwun
It’s in point of fact a great and useful piece of info. I’m satisfied that you simply shared this useful information with us.
Please stay us up to date like this. Thanks for sharing.
Situs Terbesar