Solved

Walk thru form, hide all flash object

Posted on 2006-07-11
3
1,836 Views
Last Modified: 2012-08-14
Hi, I need a bit of JS code that's super-cross-browser compatible (FFox, Safari, Windows IE 6 or better) to walk through a page and for every Flash movie it finds (<embed> or <object> tag, really, I think), it needs to change the display=none or display=block. (I'm loading a CSS layer on top of them, and Flash movies REALLY hate having something load on top of them, so I think the best thing to do is just hide the Flash movies temporarily while I load the top content. It ain't glamorous but it should work...)

I've tried to bang this out myself but can't even figure out how to get JS to give me a list of all embeds/objects on the page, let alone do something with 'em ;-)
0
Comment
Question by:pnoeric
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 26

Accepted Solution

by:
DireOrbAnt earned 500 total points
ID: 17087445
<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
function ChangeVisibilityForClass(ClassToHide, Visibility) {
  var ToHide = document.getElementsByTagName('DIV');
    for(var i=0; i < ToHide.length; i++){
              if (ToHide[i].className && ToHide[i].className == ClassToHide) ToHide[i].style.visibility = Visibility;
    }
}
</SCRIPT>
</HEAD>
<BODY>
<A HREF="javascript:ChangeVisibilityForClass('FlashDiv', 'hidden')">Hide All Flash Movies</A><BR>
<A HREF="javascript:ChangeVisibilityForClass('FlashDiv', 'visible')">Show All Flash Movies</A>
<P>
<DIV CLASS="FlashDiv">My Flash Movie 1 in here</DIV>
<DIV CLASS="Whatever">Keep this one</DIV>
<DIV CLASS="FlashDiv">My Flash Movie 2 in here</DIV>
</BODY>
</HTML>
0
 
LVL 17

Expert Comment

by:mreuring
ID: 17089054
Hmmm, how about just setting a class on the body and write some simple CSS selectors to match your flash? The same class on the body can be used to trigger the element that you're about to show on top of them. Everything could be contained in a function as simple as:

function flipFlopClass (element, class) {
   var ffRE = new RegExp(" ?\\b" + class + "\\b");
   if (ffRE.test(element.className)) element.className = element.className.replace(ffRE, ""); //Remove the class if it's already in
   else element.className += " " + class; //Add the class if it's not already set
}

And your css could be as simple as:

body.overlay object, body.overlay embed {
visibility: hidden;
}

body.overlay div.myoverlay {
display: block;
}

Hope this helps,

 Martin
0
 

Author Comment

by:pnoeric
ID: 17097183
Martin, love where you're going with your solution, but not completely sure how to use it ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question