Skip to main content
Home  › ... 2sxc Apps

turnOn Tutorials

Tutorial Home

Activate turnOn and execute basic tasks

This page activates turnOn and executes a JavaScript function using turnOn.

In this tutorial you'll learn how to:
  • Activate turnOn using the PageService
  • Execute a JavaScript function on initial loading
Look at the text below to see the effect.
turnOn is waiting - this will be replaced within 3 seconds... 😔

Source Code of this file

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Source Code of _100-local js.js

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Use an IFFE to ensure the variables are not exposed globaly
// See https://developer.mozilla.org/en-US/docs/Glossary/IIFE
(() => {
// The init function which should be called
function init() {
// Example element gets found in the DOM
const exampleElement = document.querySelector("#turn-on-example")
// Success text gets displayed in the DOM
exampleElement.innerText = "turnOn has been executed. 😉";
}
// For demo purpose, wait 3 seconds before we add the object and Init
// This should simulate slow loading of a JavaScript
setTimeout(() => {
// Generate a new object if none exists yet (best practice)
window.turnOnTutorial100 = window.turnOnTutorial100 || {};
window.turnOnTutorial100.init = window.turnOnTutorial100.init || init;
}, 3000);
})();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX