What does 'postMessage()' do when called on an object tag?

Posted by Stephano on Stack Overflow See other posts from Stack Overflow or by Stephano
Published on 2010-03-08T15:14:12Z Indexed on 2010/03/08 15:36 UTC
Read the original article Hit count: 313

I was recently searching for a way to call the print function on a PDF I was displaying in adobe air. I solved this problem with a little help from this fellow, and by calling postMessage on my PDF like so:

//this is the HTML I use to view my PDF
<object id="PDFObj" data="test.pdf" type="application/pdf"/>

...
//this actionscript lives in my air app
var pdfObj:Object = htmlLoader.window.document.getElementById("PDFObj");
pdfObj.postMessage([message]);

I've tried this in JavaScript as well, just to be sure it wasn't adobe sneaking in and helping me out...

var obj = document.getElementById("PDFObj");
obj.postMessage([message]);

Works well in JavaScript and in ActionScript.

I looked up what the MDC had to say about postMessage, but all I found was window.postMessage.

Now, the code works like a charm, and postMessage magically sends my message to my PDF's embedded JavaScript. However, I'm still not sure how I'm doing this. Any ideas?

© Stack Overflow or respective owner

Related posts about html

Related posts about object-tag