Event listener HTML Object

Hey guys, I have a timer to jump to a certain scene after 10 minutes of inactivity. That timer is resetted by every click or swipe in my window. I am using this code:

window.tenmins = 600000;
window.timer_10_mins = setTimeout(function () {
        hypeDocument.showSceneNamed('screensaver', hypeDocument.kSceneTransitionInstant);
    }, tenmins)
window.addEventListener('mouseup', function () {
    clearTimeout(window.timer_10_mins);
    window.timer_10_mins = setTimeout(function () {
        hypeDocument.showSceneNamed('screensaver', hypeDocument.kSceneTransitionInstant);
    }, tenmins)
});

On one of our scene i have placed an HTML-widget, containing an object showing our website by using:

  <object data="https://www.xyz.com"></object>

Apparently i cannot listen to clicks within this object to reset my timer and after 10 mins the document automatically jumps to my screensaver-scene.

Do I need to do something else or am I missing something here?

My understanding is that general this isn't possible - the window object in your iframe is different than in the parent frame, and browsers pass all clicks through into that before generally giving you opportunity to do anything. The best you could do would be prevent all mouse events to go to the iframe (via pointer-events:none/Hype's "Ignore all pointer events") but it sounds like you still want interaction.

I've seen some tricks online that listen to the onblur handler for the iframe to reason about being a click, but I suspect this only works once and probably has other caveats.

The only real way to solve this would be to have code in your iframe that can communicate back to the parent. If you are on the same domain, you do have access to the window.parent property, which is usually the easiest way to do this.

1 Like

Thank you @jonathan, meanwhile i made it possible for iframes with data coming from the same domain (e.g. the resources folder), but listening to clicks on a website from a local file does not seem to be professionally possible indeed.

I will try to paste some code to the website, if possible.
Thanks again!

1 Like