473,222 Members | 1,795 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,222 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 3799
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");
  3.     so.write('DIV.ID.TO.RENDER.MOVIE');
  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;">';
  8.     $('DIV.ID.TO.RENDER.MOVIE').show();
  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.

Sep 12 '07 #2
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

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...
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...
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...
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...
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...
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 :
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...
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...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.