PDA

View Full Version : Swf in iframe caling JavaScript


Crismo
02-12-2004, 09:23 AM
Having some trouble with flash / JavaScript / iframes

I have made tow files Test1.htm and Test2.htm
Test1.htm holds tow iframes both linking to Test2.htm, the difference is the location.
The first instance of Test2.htm is located on the same server as Test1.htm
The second instance is located at another server.

Test2.htm holds one html push button that triggers the JavaScript function TestFunction.
It also contains a flash movie with a button that triggers the same function.

And this is the weird part.
The flash movie and bush button in the first iframe both trigger the JavaScript function.
But in the second iframe (the one that links to a different server) only the push button works.

I have tried moving the JavaScript function to the Test1.htm. No effect.
I have tried hard coding the “address” to the script ( frames[0].window.TestFunction();) . No effect.
And lots of other combinations, nothing seams to get the second flash button to trigger.

Any ideas to a solution / workaround would be really appreciated

splict
02-12-2004, 12:39 PM
I don't think you can write javascript to a file on a diiferent server than the one that is calling it. I believe this is for security reasons. So your pushbutton, calling the javascript, will look like its just not doing anything.

Crismo
02-12-2004, 04:16 PM
It was my first thought as well. But it doesn’t hold water.
I tested this theory by adding a html push button to the same file (Test2.htm) and this butt on works in both instances.

I prepared an example at http://www.crismotec.net/Test1.htm to show what I mean.
It’s the same script on all the buttons, and it’s the same flash movie being used in all three cases.

splict
02-12-2004, 04:23 PM
not sure I understand. I see 3 buttons.
1 local - no iframe works
2 local - iframe works
3 external - iframe. doesn't work
Results are what I would expect. I am probably misunderstanding things :(

Crismo
02-12-2004, 04:50 PM
I am probably explaining it like a mad cow :)
In frame three the non flash button is capable of calling the JavaScript function.
This suggests to me that the problem isn’t a security issue (since the script can be triggered by an html push button). And the script isn’t actually remote data ? (its already loaded and shouldn’t require a post back to function) .
But I guess my reasoning could be terrible wrong.

I am going to try placing the script within Test1.htm and give the flash movie script a fully named path to it. Not what I wanted, but it might prove to be a solution.

splict
02-12-2004, 05:09 PM
Actually, the confusion is mine. I missed something when looking at your test page. What is your code in your .swf for calling the alert?

Crismo
02-12-2004, 06:02 PM
I have tried several solutions (the name of the javascript function is Jalla)
1. getURL("Javascript:Jalla()");
2. getURL("Javascript:window.Jalla()");
3. getURL(“Javascript:frames[1].window.Jalla()”);
4. getURL(“Javascript:frames[‘qz’].window.Jalla()”);

Doesn’t seam to work though.

Crismo
02-13-2004, 07:36 AM
It seams we where initially right.
It is a security problem.
Flash dos not allow running JavaScript’s in frames across domains.
Something about preventing you from jacking content across domains and displaying it as your own stuff.
I don’t quite see how disabling JavaScript’s solves this problem.
Well I guess its time to start looking for a new solution. :(