to enter code enclose the code in one backtick, for inline code
`<like this />`
or within 3 backticks on separate lines
```
var like = "this";
```
Difficult to give you more as the context of why you have this code is a little unclear. Could you elaborate?
Do you want to show scene ‘b’ from the same document?
The main problem is that you have the function in the head HTML. Here, when using hypeDocument it will throw an error saying undefined for hypeDocument (basically the browser, at that point … in the head HTML doesn’t know what hypeDocument is.) hypeDocument is an argument passed in all functions created in your document.
You could set up the function in the same On Scene Load function that does the same thing but allows you to use hypeDocument … like this.
@steve_wolk
I assume this line would be for selecting which Scene to go to? (Currently it appears to do nothing.)
i.e. "Health Service" would got to "Scene b"; "Dental Service" would go to a "Scene c", etc.
hype’s got its own eventsystem to be called from ‘outside’ (in your case the head section). it enables ‘normal’ support for the hype-API (like within hype)
so create a hype-document-load-listener in the head:
<script>
function myCallback(hypeDocument, element, event) {
//this'll be your custom function:
hypeDocument.customFunction = function(e){
console.log(e.target)
}
return true;
}
if("HYPE_eventListeners" in window === false) {
window.HYPE_eventListeners = Array();
}
window.HYPE_eventListeners.push({"type":"HypeDocumentLoad", "callback":myCallback});
</script>
on sceneload do your populating stuff:
var a = document.createElement('a');
a.href = '#';
a.setAttribute('class', 'myClass');
a.setAttribute('id', 'myId');
var t = document.createTextNode("Hello Hype");
a.appendChild(t);
hypeDocument.getElementById('xxx').appendChild(a);
a.addEventListener('click', hypeDocument.customFunction);
hope i got you right and this’ll simplifie stuff for you …