Javascript in other pages

Hi there,

So, I have a route, such as:

var routes = [
  {
    path: '/about/',
    url: './about.php',
  }, ...

And I have a link, such as:

<a href="/about/?var1=val1">

I would like to add javascript to the page I’m loading, such as:

<div class="page" data-name="about">
   ...content...
</div>
<script>
  alert("hello");
</script>

However, it seems that nowhere I put the script code, it doesn’t run. Inside the page div, outside, wherever. Do I HAVE to run script from the main page? Or can I somehow run javascript from within the page I’m loading?

Thanks!

You need to use proper Router components if you want to keep page-specific scripts in page file https://framework7.io/docs/router-component.html