ouyang789987 / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

swf nested in form : ExternalInterface error on IE #394

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a swf containing ExternalInterface calls to a js function
2. Insert it with swfobject *inside* a html form
3. Call your js function : all IEs throw an error saying that the called
function is not defined. Works fine in other navigator.

What is the expected output? What do you see instead?
Normaly, your js function is successfully called. Instead an "undefined
function" error is throwed.

What version of the product are you using? On what operating system?
all swfobject versions, with all IE versions.

Please provide any additional information below.
if your embed your swf outside a html form element, everithing works fine.
In IE, every time you add an “ID” attribute to an HTML element, that
element is added to the “window” element so you can access it directly
using window.elementID... but if you place the element inside an HTML form,
the element is added to the form element (document.forms[0].elementID if
you have only one form) and not window element.
So when Flash ExternalInterface API will search your swf object in
window.xxx (instead of document.forms), this will result in an "undefined
function" error...

Solution :
detect browser, and if IE, and newly created object element is nested in a
form, manualy add a reference to this element in the window objet.

A working patch for me (without nest detection) with SWFobject 2.2 : 
after line 437, (r = getElementById(attObj.id);),  add "window[attObj.id] = r;"

Regards.

Original issue reported on code.google.com by doga...@gmail.com on 26 Oct 2009 at 11:23

GoogleCodeExporter commented 9 years ago
Thanks for posting your workaround, but this is not a SWFObject specific bug. 
It is a 
known general Flash player bug (that has been around since 2006!).

The documentation even states that it is not supported:
"Flash Player does not currently support SWF files embedded within HTML forms."

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/Externa
lInte
rface.html

Steve Kamerman released a little js library back in the day to help out people 
who to 
do EI functions within a form. You can find out more if you like:
http://www.google.com.au/search?q=SWFFormFix

Here is Adobe's recommended workaround (a nested form tag seems to fix it for 
some 
reason):
http://kb2.adobe.com/cps/400/kb400730.html

Original comment by aran.rhee@gmail.com on 26 Oct 2009 at 11:24

GoogleCodeExporter commented 9 years ago
Hi, 
thanks for this reply.

In fact, my report was more about "it is a good idea to port this workaround in 
SWFObject" until Adobe fix this 
issue (that is surely not probable) ?

Maybe it's a good point if developper can say one day "SWFObject embed this 
workaround"...

And about nested form tag, it seems that is not a good idea, since it is not 
permitted in W3C 
recommendations...

By the way, thanks for all the works on SWFobject

Original comment by doga...@gmail.com on 27 Oct 2009 at 12:21