There is a small flash banner on the page.

<div class="banner"> <object type="application/x-shockwave-flash" ... data="images/MP_banner.swf" > <param ....../> <img src="images/banner.jpg" .... /> </object> </div> 

in theory, when you click on it, you need to open a large flash banner with a roller. But for this purpose a small picture was made. and a function on click is attached to it on jquery

  <div class="presentation"> <img src="images/presentation.jpg" alt="" /> </div> 

here is jquery

 $('.presentation').click(function() { $('#flashContent').show().animate(); $('#page').fadeTo('1000', 0.3); return false; }); 

How can you get rid of this 2nd stage, and open the video when you click on the banner right? I say in advance!

 $('.banner').mousedown(function() { ... НЕ РАБОТАЕТ ... }); 
  • $ ('. banner object'). mousedown (function () {... AND SO DOESN'T WORK? ...}); ZY Just interested. - Palmervan
  • As far as I know - in any way, either call the javascript handler with the flash. - Zowie
  • No, it does not plow - armenka
  • "call javascript handler with flash" does not plow? xDDD - Zowie
  • I understand you here - Zowie

2 answers 2

You can create a div on top of the banner with its size, but then the flash object will not be able to handle mouse events

 var bannerContainer = $('.banner')[0]; var bannerOverlay = $('<div/>') .css({ "position": "absolute", "width": bannerContainer.width(), "height": bannerContainer.height() }) .offset(bannerContainer.offset()) .click(function() { /* ... */ }) .appendTo('body'); 
  • does not roll! flash banners they are always above the blocks. therefore, a click to .banner did not reach. and here, too, does not work. - armenka
  • It must be <param value = "transparent" name = "wmode">. Well, you can force a z-index for .banner (for example, z-index: 1) and for an overlapping diva (z-index: 2). position-absolute + z-index decide everything :). Here I have a working example: shans.su There, among the banners, flashbacks sometimes spin, and on top of the flashs, you need to show a drop-down list of cities (top right). It even works in IE6 - oleg42
  • @armenka, not sure, but try wmode flash to flash opaque or transparent. For by default it is a window and is always above all, and transparent can be covered over the html. - Sh4dow

Try this:

 $('.banner object').mousedown(function(e) { ... e.stopPropagation(); }); 

Only here there are unclear glitches with the flash itself (it is highly undesirable to process MouseEvent.* ), And in some browsers a flash download is required.

UPDATE

I made an example: jsbin.com/ovugel/3 , although with jQuery (the .mousedown call) I didn’t start for some reason, but I’m too lazy to figure out what the jQuery problems are.

UPDATE 2

Some kind of ambush with jQuery, it works only this way:

 $('.banner object').live('mousedown', function(e) { ... e.stopPropagation(); }); 

Why is it - no one answered me, although I specifically asked for this question number 70380

  • "flash download required" You can ask - in what form? - Zowie
  • Well .swf file will come to the computer completely (sometimes they are loaded for a long time) - chernomyrdin
  • Clearly, I understand that you will not recommend using this approach? =) - Zowie
  • There are 2 rollers 1 in the form of a banner, it is maaaalenky and hangs on the sidebar; Now he is called when clicking on a link with the inscription to watch a video ... - armenka
  • so it’s impossible to replace a small banner with an html element? .. Yes, and IMHO, 100%, it’s more logical, in that case, to call the handler from the flash - Zowie