Dear @dani
have a look on my test page:
http://www.laytheme.mariusjopen.com/javascript
This is the code which gets triggered
<script>
alert("TEST");
jQuery( "body" ).addClass( "TEST" );
</script>
0_1532166521502_Bildschirmfoto 2018-07-21 um 11.48.33.png
The function gets triggered if you open the page with URL or when you open it via another page.
Best!
Marius