IframeのIframeのデータにアクセスしようとしています。javascript関数を強制的に待機させるには、jqueries.load関数を使用します。しかし、それでも私のjavascriptコードは、iframeのコンテンツが完全に読み込まれる前に「時々」実行されます。時々私は、動作がコンピュータごとに異なることを意味します。低速のコンピューターでは、ほとんどの場合、高速のコンピューターがコードを実行するのを待ちます。したがって、InternetExplorer8がonloadイベントを早期に発生させたのではないかと思います。iframeのすべての要素が読み込まれるまで待機するjquery関数はありますか?
これは私のコードです:
function parsePeopleLink(){
try{
//This is where I check if the wanted I frame already exists
if(document.getElementById('isolatedWorkArea') != null) {
if(window.frames[2] != null) {
if(window.frames[2].name == 'isolatedWorkArea') {
//This is where I want the following code only to be executed when the Iframe's content is fully loaded, otherwise I get an access denied error when trying to change Userlinks
$('#isolatedWorkArea').load(function() {
for( var i = 0; i < window.frames.length; i++){
for(var j = 0; j< window.frames[i].document.frames.length; j++){
IframeDocument = window.frames[i].document.frames[j].document;
changeUserLink(findPeopleIDfix(findPeopleID(IframeDocument)),findUserLinks(IframeDocument),8, IframeDocument);
}
}
});
}
else {
throw e; //I know that all the nested else statements are ugly, I just inserted them for testing purposes
}
}
else {
throw e;
}
}
else {
throw e;
}
}
catch(e) {
//alert(e.description);
for(var k = 0; k < window.frames.length; k++)
{
IframeDocument = window.frames[k].document;
changeUserLink(findPeopleIDfix(findPeopleID(IframeDocument)),findUserLinks(IframeDocument),9, IframeDocument);
iframeindex++;
}
}
}
すべてのIframeには、同じポート、protocol、およびsrcがあります。ヘルプは大歓迎です