views:

306

answers:

2

After working for a prolonged time on a programming problem, I start to get coding tunnel vision. It makes it harder to draw back and look at the problem from farther away.

Hence my question: I am using a Drupal 6 site. When a menu option is clicked, the page opens and a Flash SWF file needs to played in a ThickBox. After 8 seconds, that Thickbox closes.

Opening the SWF file in the Thickbox when a link is clicked is no problem, just like closing the Thickbox afterwards; that's basic javascript. For that I use these:

document.getElementById("identifyvideo").style.display="none"; var tim = window.setTimeout("hideMessage()", 5000); //hide that layer after 5 seconds

But opening the Thickbox on load? I can add a link for the user to click, but it should open automatically. I figured out the PHP to have it only open on one specific page. From the Thickbox manual, I learned to open links to images - but not how to open it when the page loads.

A: 

Drupal used jQuery, which has an event that is fired when the page has loaded.

$(document).ready(function () {
    // Put code here will be run when page has loaded.
});
googletorp
A: 

Yes, thank you! I figured it out before you answered my question - but I was on the right track. I used Shadowbox with this code:

<script type="text/javascript"> 
Shadowbox.init({
    language:   "en",
    players:    ["swf"]
});
</script>

<script type="text/javascript"> 
window.onload = function(){ 

Shadowbox.open( document.getElementById('identifyvideo') ); 
setTimeout("Shadowbox.close()",9000);

};
</script>

...where #identifyvideo was the DIV that holds the SWF file. Thanks for your feedback!

Wouter Haesaerts