Calling a function in Hype from an iframe


(steve) #1

I’ve got a page with Hype in the parent document and I want to call a Hype function from the child - iFrame.

I’ve been trying using the code in this Hype Forum thread:

I’ve tried two variations, neither of which work:

window.parent.HYPE.documents[‘myDocumentName’].functions().myFunctionName(HYPE.documents[‘myDocumentName’]);

and

window.parent.document.HYPE.documents[‘myDocumentName’].functions().myFunctionName(HYPE.documents[‘myDocumentName’]);

Any thoughts on how to make this work?


(Jonathan Deutsch) #2

The first variation is the correct one. I would look at the developer console to see what is being logged.

One thing to note is that when previewing, the document name will be “index” whereas exporting will be what you named it at export time.

Here’s an example:
index.hype.zip (12.9 KB)

I’m just calling:

window.parent.HYPE.documents["index"].functions().untitledFunction();