Page cover

Javascript

Javascript is the third layer of the standard web technologies that lives on top of HTML and CSS.

JavaScript can manipulate the HTML elements and add interactivity.

For instance, you can use JavaScript to add interactivity to websites, validate forms or track users' actions on a website. So yeah, big part of web tracking is powered by javascript.

If you want your web page to do more than just sit there and display static information, you need to implement JavaScript to make it more interactive.

“Alright, I know you more than anyone in the Academy. So you sneaking out in the middle of the night to go after the signals is a very high probability. I believe I just wanted to protect you, you know.” said Kyle. The anger on Red’s anger seemed to dissolve into a more innocent and caring expression. “I hate it when I feel like you can read my mind. This was the first idea that occurred to me the second you told me that the signal was lost.” - Journals of Order of Epoch, 2341 Anno Domini

So think of javascript as the third layer of the standard web technologies that lives on top of HTML and CSS.

So let's put Javascript in action, shall we?

We have already created a beautiful login page using HTML and CSS. Now we would like to verify whether the inputs we collect are indeed in the format we requested. We can set up a validation mechanism through Javascript. Thus, we can take a measure to ensure the accuracy and correctness of the data collected from the data subjects.

function ValidateEmail(inputText)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(inputText.value.match(mailformat))
{
alert("Valid email address!");
document.form1.text1.focus();
return true;
}
else
{
alert("You have entered an invalid email address!");
document.form1.text1.focus();
return false;
}
}

We can go even further and use more complex snippets of Javascript to measure the people who come to the page where the login form is located but did not provide any inputs.

So we might want to get some metrics and measure how well our registration form tunnel is working. By adding a tracking code, we can start measuring incoming visitors. We will need to obtain the explicit consent of the users in order to make the follow-up we want to carry out here in compliance with the law. We can start the user tracking we want to perform by adding the following piece of code to our registration form page.

<script type="text/javascript"

  var _paq = window._paq = window._paq || [];

  _paq.push(['trackPageView']);

  _paq.push(['enableLinkTracking']);

  (function() {

    var u="//{$VERILOGY_URL}/";

    _paq.push(['setTrackerUrl', u+'matomo.php']);

    _paq.push(['setSiteId', {$IDSITE}]);

    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];

    g.type='text/javascript'; g.async=true; g.src=u+'verilogy.js'; s.parentNode.insertBefore(g,s);

  })();

</script>>

So there you go, your first step into to start getting used to why you'd use JavaScript and what kind of things you can do with it.

Last updated

Was this helpful?