How to load js script after clicking the link?

0 like 0 dislike
3 views
Good afternoon.
There is a script using jquery as the basis. It takes information from a multidimensional array and replaces the existing information. And it works if the page refresh in the browser, or just open it as a new tab, and pasting the url.
But when going from another page, it does not work!
There is a page index.html. On this page there is a link catalog.html.
On the page catalog.html is this script.
and clicking on the link index.html on catalog.html the script does not work.
Help if know the reason.!

Even this script does not work
$(window).on('load', function(){ console.log('sss'); }); console.log('aaa');
by | 3 views

2 Answers

0 like 0 dislike
Well, you used the plugin smoothState.js to navigate through the pages without reloading the page. In block #page-transitions is of contenta the part that is unique to each page, so she will make friends dynamically. The rest does not change, so the script is not re-executed (can see in F12, a piece of the script does not change when switching pages).
Try to put the script in the block #page-transitions then it will run.
by
0 like 0 dislike
Silkey
Menu > Catalog > Classic catalog
Then in the console
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,964 users