www.webdeveloper.com
Results 1 to 4 of 4

Thread: javascript function call after event onload

  1. #1
    Join Date
    Aug 2004
    Posts
    36

    javascript function call after event onload

    Hey,
    I have a pop up window that has a flash player inside. The player is a jukebox for music. From the parent window when you press the button to add a track, the pop up opens and the track is added. The problem is that the YAHOO eventListener (or even the window onLoad function) gets called when the window opens but before the flash player opens. So I always get an error when my javascript function calls to the flash player, because the window opens and the function gets called then the player opens.
    The only way it works is if I add an alert when the pop up opens. It seems to pause just enough time to allow the window to open and the player to open then calls the function, but I don't want to open an alert all the time for no reason.
    Another way I thought it could work is to open another pop up window outside of the view of the screen and then close it right away. But is there anything else I could do?

    Cheers,
    Jason

  2. #2
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,203
    You could possibly try having the onload function call the original function after a set time and experiment with the delay time

    onload=function init(){

    setTimeout("originalFunction()",1000)

    }

  3. #3
    Join Date
    Aug 2004
    Posts
    36
    Hey, that is a good idea. The only problem is that my function takes an argument and i cannot succeed in placing it inside the timeout function.

    Ex:
    Code:
    	function addTrack(trackId){
    		
    		var isIE = navigator.appName.indexOf("Microsoft") != -1;
    		if(isIE){
    			flashMovie = player.window["add-player-as3"]
    		}else{
    			flashMovie = player.document["add-player-as3"];
    		}
    		flashMovie.addTrackById(trackId,true,true);
    		
    	}
    Code:
    setTimeout("addTrack(trackId)",1000)
    The trackId variable is not recognized. Is it possible to pass an argument like this inside the setTimeout() function?

    Thanks
    Jason

  4. #4
    Join Date
    Aug 2004
    Posts
    36
    I got it

    Code:
    setTimeout(function(){functionToCall(parameterToPass);},timeOutTime)
    just in case there are others who would like to know.

    Cheers,
    Jason

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles