views:

18

answers:

3

Hi I have a master page and a child page and have placed the javascript code inside the child page for flash movie.

The problem is the movie seems working when there is a alert on, without at least one alert msg, the code does not work, I am sure you people can solve, I can see that the following code works well in both Mozilla and IE, but only if the alert is ON, if I put it off, then the code does not work. Can anybody tell me what is the workaround :

function getFlashMovie(movieName) { alert(''); // if I remove this , code does not work!!!!!! if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); }
}

Regards arunendra

A: 

You need to put a short timer where your alert code is. Have this timer sleep just a little so the window.document can be ready for you to load the movie. But this is a slight hack.

You can also load the flash in jQuery's $document.ready() to take care of your issue; which would probably give you better results and it is definitely better from the coding aspect.

TheGeekYouNeed
A: 

Hi

I tried the loop, did not work, tried the settimeout, it does not work first time in ie, but works after a refresh, and does not work at all in firefox. I do not know how to use jquery in this respect, so can you please show me how to do it.

thanks for your support.

regards arunendra

arunendra
A: 

Hi

Finally I have found the solution, in case anybody runs into the sane problem, here is the answer:

just pass the function in the window.onload event

window.onload = view_gallery;

function view_gallery() { var x = document.getElementById('hiddenfield').value;
getFlashMovie("galleryfinal").sendTextToFlash(x);

    }

function getFlashMovie(movieName) {

if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); }

}

thanks arunendra

arunendra