type:
integration
system:
Flash
name:
Hide Flash on FoxyBox load
description:
Hide flash objects when the Thickbox is launched, and show them again when it's closed.
tag:
flash, foxybox
date:
2008-03-05

Hiding Flash on Modal Window Load

Please note: The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please post in our forum, but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.

Description

If the pages that launch your FoxyBox cart also contain flash objects, you may encounter some display conflicts. Specifically, flash objects can overlay your cart and obstruct its view, which is obviously not good. The release of ThickBox 3 (on which FoxyBox is based) should have fixed most cases of this problem, however there are still some lingering browser/platform combinations that need some help.

To fix this, simply use javascript to hide the flash objects when the ThickBox is launched, and show the objects again when the box is closed. Two functions created for the JSON cart object, can be defined which let you access these events easily:

// called before ThickBox is opened	
function fc_PreProcess() {
	hideFlash();
	return true;
}
// called when ThickBox close button is clicked
function fc_BuildFoxyCart() {
	showFlash();
}

As for the functions hideFlash() and showFlash(), you can borrow from the distrubutions of ThickBox-like scripts. The following were taken from the excellent Lightbox 2 script:

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}
 
	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}
 
// ---------------------------------------------------
 
function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}
 
	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}
 
}

Site Tools