Thanks a lot Pillip, I'll give it a try.
On Apr 21, 10:26 pm, Philip Hutchison <[email protected]> wrote:
> in order to embed a SWF in a document, the document must have the SWFObject
> script in its <head>.
>
> if a script in your iframe is trying to embed a SWF in the parent HTML file,
> the parent must first have swfobject.js linked in the <head>.
>
> you should then be able to reference swfobject through the window object:
>
> var targetID = "myID";
>
> //Create and append the empty div
> var myDiv = window.parent.document.createElement("div");
> myDiv.setAttribute("id", targetID);
> window.parent.document.body.appendChild(myDiv);
>
> //embed a swf into the empty div
> window.parent.swfobject.embedSWF("foo.swf", targetID, "550px", "400px",
> "8");
>
> gotchas:
>
> 1. as i mentioned, this will only work if the parent has the swfobject.js
> file in the <head>.
> 2. this will only work if the iframe and the parent are on the same domain.
> if they're from different domains, cross-domain security restrictions will
> kill your script (the iframe won't be able to access the parent and
> vice-versa).
>
> - philip
>
> PS: i didn't test the code, so there could be a bug or two, but you should
> get the idea.
>
> On Mon, Apr 20, 2009 at 1:42 PM, Getify Solutions, Inc.
> <[email protected]>wrote:
>
>
>
> > I think you missed the big change in my edit of your code. You don't need a
> > reference to the DOM object itself. You need the ID ("something" in the
> > example). that you assign to that DOM object. If you don't have the ID, you
> > cannot use SWFObject.
>
> > --Kyle
>
> > --------------------------------------------------
> > From: "Bertrand" <[email protected]>
> > Sent: Monday, April 20, 2009 12:45 PM
> > To: "SWFObject" <[email protected]>
> > Subject: Re: Referencing an element in call to embedSWF
>
> > >> Try this, as it should work:
>
> > >> var myDiv = document.createElement('div');
> > >> myDiv.id = 'something';
> > >> document.body.appendChild(myDiv);
> > >> swfobject.embedSWF('flash.swf', 'something', ....);
>
> > > Unfortunately, as specified in my first post, I'm inserting the div in
> > > the parent document from a script that resides in an iFrame by doing
>
> > > var target = window.parent.document;
> > > target.body.appendChild(myDiv);
>
> > > Meaning that I can modify the DOM of the parent from the iFrame and
> > > append the div, but I can't just put the reference to myDiv in the
> > > call to SWFObject, since that div resides in the parent,
> > > not the iFrame from where embedSWF is called.
> > > Thus my need to be able to specify a DOM path to the parent, something
> > > like embedSWF('myFlash.swf', target.getElementById('myDiv'),....)
>
> > > I' not sure if I'm being clear here, English isn't my native
> > > language :)
>
> > >> As for the jQuery extension thing, here's a jQuery plugin for SWFObject,
> > >> though I'm not so sure on how much of its internals are really SWFObject
> > >> natives:
>
> > >>http://jquery.thewikies.com/swfobject/
>
> > >> (bonus, that plugin even has its own theme song! listen and enjoy!)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SWFObject" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/swfobject?hl=en
-~----------~----~----~----~------~----~------~--~---