sirfree
(Jon)
August 17, 2015, 5:55pm
1
Ok I need to call a scene to be displayed and need to do it from a iframe. this is what I thought the scrip should look like.
window.parent.hypeDocument.showSceneNamed(‘Consumption’, 2, 1.1)
Consumption is the scene name but I get a error function not found. Can someone please help?
Thanks,
Jon
DBear
August 17, 2015, 7:46pm
2
Hi Jon
In your head.html include this:
<script>
function myCallback(hypeDocument, element, event) {
window.myhypedocument = hypeDocument;
}
if("HYPE_eventListeners" in window === false) {
window.HYPE_eventListeners = Array();
}
window.HYPE_eventListeners.push({"type":"HypeDocumentLoad", "callback":myCallback});
</script>
Then in your html widget (iframe) something like this:
<div onclick="window.parent.myhypedocument.showSceneNamed('Consumption');">
NextScene
</div>
Edit* By the way this was curtesy of @h_classen in another post.
Hope this helps!
D
sirfree
(Jon)
August 17, 2015, 9:42pm
3
I get this error.
undefined is not an object (evaluating ‘window.parent.myhypedocument.showSceneNamed’)
MarkHunte
(Mark Hunte)
August 19, 2015, 11:41am
4
Hi Jon,
can you post you Project so we can see what you are doing. This will make it easier to spot the issue.
P.S.
I change your Title. I had been ignoring this post because you had Java in the title. Which is something completely different to JavaScript.
sirfree
(Jon)
August 20, 2015, 6:03pm
5
i found the error. “top.myhypedocument.showSceneName(‘Consumption’,2,1.2)” worked. I have to load data into the widgets after the webpage is loaded and in the widget is a iframe. to find the main page containing the hype controls i have to use top. instead of window.parent because the parent is the iframe widget and not the main window. Thanks for the help and the pointer to the code to put in the Header of the hype doc. That lead me to the function witch I was able to find with a debugger displaying the page.
xarc
(Aron)
August 25, 2015, 11:41am
6
Hello,
i use “this .myhypedocument. …” instead of “window.parent .myhypedocument. …” to address a (this) document in a iFrame. Is this correct?