Calling a scene to change using JavaScript


(Jon) #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?



Hi Jon

In your head.html include this:

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});

Then in your html widget (iframe) something like this:

<div onclick="window.parent.myhypedocument.showSceneNamed('Consumption');">

Edit* By the way this was curtesy of @h_classen in another post.

Hope this helps!


(Jon) #3

I get this error.

undefined is not an object (evaluating ‘window.parent.myhypedocument.showSceneNamed’)

(Mark Hunte) #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.


I change your Title. I had been ignoring this post because you had Java in the title. Which is something completely different to JavaScript.

(Jon) #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.

(Aron) #6

i use “this.myhypedocument. …” instead of “window.parent.myhypedocument. …” to address a (this) document in a iFrame. Is this correct?