Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To make Flash dissapear

Status
Not open for further replies.

leeboycymru

Programmer
Jan 23, 2007
185
GB
I am in the process of moving a website from tables to css, and all is going well so far. One of the reasons why they wanted to do this, is that when viewed on a PDA their site just didnt work, so I set about doing it in CSS.

One of the things I have noticed when i turn the CSS off is that the flash animation takes up a lot of room and is not necessary:


So is there a way of when CSS is turned off, the Flash animation goes away. leaving the rest of the animation to fall into place nicely.

cheers

Lee
 
leeboycymru said:
flash animation takes up a lot of room and is not necessary
- even more true when taken out of context ;)

Simple answer is no - not using CSS.... if styles are switched off then you can't use a style to hide the DIV that holds your flash.

However some JS that checked to see if styles were enabled might be able to do the job.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
Shame that! but thanks...

To save time, do you have a link to that jscript solution.

Thanks again

Lee
 
Should be a matter of interrogating the styled properties of some element and seeing if they match up to what you know they should be in your stylesheet:
Code:
<style type="text/css">
.myFormat {
	font-family:Arial, Helvetica, sans-serif;
	font-size: x-large;
	font-style: italic;
	font-weight: bold;
	background: rgb(255,51,153);

}
</style>
Code:
function checkStylesExist(){
	//Get a handle on an element that we know we've styled
	var styledElement = document.getElementById("flashContainer");
	var stylesExist = false;
	if(document.defaultView && document.defaultView.getComputedStyle){// For firefox
		var elementStyle = window.getComputedStyle(styledElement, ""); 
		var strBGColour = elementStyle.getPropertyValue("background-color");
		if(strBGColour == "rgb(255, 51, 153)"){
			stylesExist = true;
		}
	}
	else{	//most likely ie
		var strBGColour = styledElement.currentStyle.backgroundColor;
		if(strBGColour == "rgb(255,51,153)"){ 	//note that IE has no commas between the values
			stylesExist = true;					//and will also render hex values literally
		}
	}
	if(!stylesExist){ //If no evidence of style was found
		styledElement.style.display = "none";
	}
}
window.onload = checkStylesExist;

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
I'm looking at this now, and in honesty I dont quite understand what is going on.

Is the .myFormat the Div that is holding the flash? and then I dont see the connection to it in the script.

Any chance of a bit of a break down of the above.

Cheers

lee
 
Is the .myFormat the Div that is holding the flash? and then I dont see the connection to it in the script.
No. .myFormat is just an example style. The code could just as easily check for any element to which you know you have applied some style rule in the CSS.

The logic is fairly simple. Your CSS will apply some style rules to various elements in the page yes? Therefore, if we examine one of the elements which you know has a style applied to it by the css we can assume that:
a) if the style of that element is as specified in the css then the style sheets are on, and,
b) if the style of that element differs from what is specified in the css then the style sheets are off.

Any chance of a bit of a break down of the above.
I'm not sure what you're asking for. You check a style of an element that should you know should be X... if it's not X then you hide the flash.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
Ah, I see.

I think I went blind last week, today I can see the wood for the trees!

Thanks again, for your help

lee
 
No sweat. Glad to help.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top