0

I'm working on a single page app, every time I click a link e.g., the event is stopped, and request to template.php with the parameters of the link. (A link with href="www.site.com/login" would request to template.php?path=login)

But there is javascript in my login page, and currently it's added to the body in a script tag, but it's never executed.

Is there any way to execute asynchronously loaded javascript like in the example above?

  • How much debugging have you done? Have you looked in the dev tools console/network tabs to see if there are any errors? – Andy Oct 14 '22 at 16:39
  • If you add a ` – Barmar Oct 14 '22 at 16:46
  • 1
    Note that scripts are not executed if the tag is assigned using `innerHTML`. You need to use `document.createElement("script")`. See https://stackoverflow.com/questions/1197575/can-scripts-be-inserted-with-innerhtml?noredirect=1&lq=1 – Barmar Oct 14 '22 at 16:47

1 Answers1

-1

I added the javascript using innerHTML. After I tried it using document.createElement("script") it worked