Page 1 of 1
JavaScript not working in header file
Posted: Sun Oct 05, 2025 11:19 am
by ClarusAD
Hello,
When i write some JS code in the header file
flatpress/fp-interface/themes/leggero/header.tpl
For example :
Code: Select all
{literal}<script> alert() </script>{/literal}
That doesn't work, and i don't understand why…
Can someone help me ?
Thank-you in advance
Re: JavaScript not working in header file
Posted: Mon Oct 06, 2025 12:38 am
by fraenkiman
Hello ClarusAD,
Try using
Code: Select all
{literal}<script nonce="{/literal}{$smarty.const.RANDOM_HEX}{literal}">…</script>{/literal}
Or with externally integrated JS:
Code: Select all
<script nonce="{$smarty.const.RANDOM_HEX}" src="{$smarty.const.BLOG_BASEURL}fp-interface/themes/leggero/res/custom.js" defer></script>
Otherwise, your browser will block the execution of the inline script.

- Screenshot 2025-10-06 024126.png (102.38 KiB) Viewed 366 times
Have a great start to the new week.
Best regards,
Frank
SOLVED Re: JavaScript not working in header file
Posted: Mon Oct 06, 2025 4:42 pm
by ClarusAD
Thank-you Fraenkiman, you're a king ! The soluce was to add the "nonce" part :
Code: Select all
{literal}<script nonce="{/literal}{$smarty.const.RANDOM_HEX}{literal}">…</script>{/literal}