473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problems with Safari 'blur' and 'focus' events on a Flash Movie

Hi there all,

Using prototype.js I render a flash movie within a DIV dynamically and then I try to attach some events in order to maintain focus on main window cuz is responsible of event handling some keyboard events -ie.

Expand|Select|Wrap|Line Numbers
  1. Event.observe(document,'keyup',function (e) {
  2. // code here
  3. });.
The problem is that when somebody clicks a button within the flash movie, the document and/or window event handlers for keypress or keyup do not work at all. To workaround that problem I did the following:

Expand|Select|Wrap|Line Numbers
  1. Event.observe($('flashmovieid'),'focus',function () {
  2. $('flashmovieid').blur();
  3. });
With other browsers but Safari, this work fine, it seems that returns control to the document event handler and I can return to capture document key events... In Safari looks like it cancels somehow the document event bubbling. I manage to get mouse events to work and I tried to make the movie loose focus to capture again document key events but no luck at all...

Any help will be highly appreciated
Sep 11 '07 #1
2 3805
Hi there all,

After I broke my head against a wall trying to find a solution, I found the most primitive one (try to capture focus and blur events on a text field to return keyboard events trapping to the document).

The problem relied that Safari 3 do listen 'blur and focus' events over a FLASH MOVIE (embed) objects. At least, I could not find a solution for that problem anywhere. Well, this was my solution, I hope I can help somebody with it:

Expand|Select|Wrap|Line Numbers
  1. var so = new SWFObject('FLASH.MOVIE.URL', 'FLASHID', "100%", "100%", "9", "#000000");
  2.  
  3.     so.write('DIV.ID.TO.RENDER.MOVIE');
  4.  
  5.  
  6.     $('DIV.ID.TO.RENDER.MOVIE').innerHTML += '<input id="FIELD.ID" type="text" style="background:#00000;width:1px;height:1px;top:0px;left:-20px;position:absolute;border:#000000 1px solid;">';
  7.  
  8.     $('DIV.ID.TO.RENDER.MOVIE').show();
  9.  
  10.     if (Prototype.Browser.WebKit)
  11.     {
  12.         Event.observe($('DIV.ID.TO.RENDER.MOVIE'),'blur',
  13. function () { $('DIV.ID.TO.RENDER.MOVIE').focus(); // return focus to field
  14. });    
  15.         $('DIV.ID.TO.RENDER.MOVIE').focus();
  16.     }
  17.     else
  18.         Event.observe($('FLASHID'),'focus',function () {
  19.             $('FLASHID').blur(); // return focus to our self window
  20.         });
I know it looks awkward but that is the solution that actually works the way I wanted.

Best
Sep 12 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

glad to hear that you found a solution for your problem ... and many thanks for sharing it here ... may be it helps other users with a similar problem ...

kind regards
Sep 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: delerious | last post by:
Please take a look at this page: http://home.comcast.net/~delerious1/index10b.html There is javascript code that is executed when the page is loaded. The code calls the focus() method and...
2
by: Chris | last post by:
I'm desperately trying to get my site finished against the clock. It looks great in FF, Opera and IE6 but falls apart in IE5 and Safari. I HAVE to have it ok for IE5.x. Has anyone got any...
5
by: Kim Forbes | last post by:
Hi, I realize my first problem is that I'm using browser detection and not feature detection. Maybe someone can help me understand feature detection. This script works in every browser that I...
2
by: drew197 | last post by:
I am a newbie. This is someone else's code which I have to modify to work in Mozilla and Safari. The changes I made so far have allowed it to work in Mozilla but not Safari. It seems to be...
6
by: dieselmachine | last post by:
Hey, I've been searching for info on this for days now, but to no avail. I'm starting to think it's impossible, but anyway! I've coded a little virtual keyboard, which has two octaves worth of...
3
by: SAM | last post by:
Geoff Cox a écrit : Didn't try but following what you say : move the mouse, it seems that Safari keeps focus on the clicked image and avoid the changing see bellow // perhaps here :
15
by: GinnTech | last post by:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. Here is the issue. I am attempting to call functions within a flash object. When trying to attempt to...
2
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.