[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Walk thru form, hide all flash object

Posted on 2006-07-11
3
Medium Priority
?
1,840 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

650 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