My first baby steps in javascript

Hi all,

I start writing in javascript and I would like to know how to get “hello world” not in a pop-up but as a text on the scene. What command do I need to do that?

1 Like

add an id to your element and run
hypeDocument.getElementById('yourId').innerHTML = 'Hello world'

2 Likes

Hi klass!

Demo Project: helloWorld.hype.zip (11.5 KB)

First give an element such as a rectangle an ID in Hype’s “Identity Inspector” in the field “Unique Element ID”. Note that there can only be one element in your project with this ID.

Then, assuming You have given the name of “demo” to to this element, create a function with the following script…

document.getElementById("demo").innerHTML = "Hello World";

This script could be set to be triggered by “On Mouse Click” etc. in Hype’s “Actions Inspector”.

You can read more about “innerHTML” here.


Taking a slightly more advanced approach You could create a variable for this element and use that instead.

var myVariable = document.getElementById("demo");
myVariable.innerHTML = "Hello World";

Read more about “variables” here.


Using Hype’s API:

myVariable = hypeDocument.getElementById('demo');
myVariable.innerHTML = "Hello World";

14%20AM

2 Likes

Here is another way using classes. I am currently experimenting with the “fleeq” plattform for help files. Hope this helps.

3 Likes

Lovely video. Like your voice. :wink:

“Fleeq, it’s free if you are alone!”

1 Like

I got the business plan :muscle:

Years of training, “Gesangsunterricht“, and some snake oil. Viola!

1 Like