Hello! People, help me figure it out. The site has a flash banner, you need to make it a link, tried everything I knew, describe the options that I tried:

The first option (the onclick attribute is registered to the OBJECT element itself) does not work, the redirect does not occur:

<object type="application/x-shockwave-flash" data="http://test.ru/banner.swf" height="150" width="200" onclick="'window.location = "http://ya.ru";'"> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="movie" value="http://test.ru/banner.swf" /> </object> 

Option 2 (did a DIV wrapper for the OBJECT element) - does not work, redirect does not occur ::

 <div onclick="redirectionLink();" style="width: 200px; height: 150px;"> <object type="application/x-shockwave-flash" data="http://test.ru/banner.swf" height="150" width="200" onclick="'window.location = "http://ya.ru";'"> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="movie" value="http://test.ru/banner.swf" /> </object> </div> <script type="text/javascript"> function redirectionLink() { window.location = "http://ya.ru"; } </script> 

The third option (created the DIV block and placed it over the OBJECT element, the onclick event registered the DIVʻu) - works only in Crhome, in other browsers my DIV is under the OBJECT element:

  <div style="width: 200px; height: 150px; border: 1px solid black; position: relative; z-index: 99999; top: -150px;" onclick="redirectionLink();"> </div> <object type="application/x-shockwave-flash" data="http://test.ru/banner.swf" height="150" width="200" onclick="'window.location = "http://ya.ru";'"> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="movie" value="http://test.ru/banner.swf" /> </object> <script type="text/javascript"> function redirectionLink() { window.location = "http://ya.ru"; } </script> 

    1 answer 1

    1. flash publish with the wmode=transparent parameter - this will allow the div container to receive JS events over the flash;
    2. catching not onclick , but onmousedown , it will work in a larger number of browsers.

    Like that:

     <div onmousedown="clickBanner(1)"> <object> <param name="movie" value="3.swf"> <param name="wmode" value="transparent" /> <embed wmode=transparent allowfullscreen="true" allowscriptaccess="always" src="3.swf"></embed> </object> </div> 

    Source of the answer .

    • Thank good man! It really worked :) - Artyomich