Listen to click on link


#1

I made an interesting page, but I had some problems. I let a other page in hype3, and then add a few elements.If I click on a link to other pages, I have no way to listen to the click on the link while running hype3 in the “txt” animation, i want it to hide.

Or if it is difficult to do so, there are ways to listen when clicking on other pages in the link is opened in a new window?

Steam.hype.zip (73.7 KB)


(Jonathan Deutsch) #2

If you are using an HTML Widget (an iframe) and need to communicate to a parent document, you could do so with a little bit of JavaScript code in the anchor tag that would look something like:

<a href = "#" onclick = "parent.window.HYPE.documents['index'].triggerCustomBehaviorNamed('behaviorName')">text link</a>

You’d need to replace index with the name of your document (note previewing always uses “index”), and behaviorName I’m using in this case as you could make a Custom Behavior to run actions, though any other item in the JavaScript API could be called.

This only works from parent to child, and they iframe must be in the same domains otherwise it will be a security policy issue. Beyond this, the method you’d need to communicate is postMessage; there was just a thread about this recently: