Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139863

Call external javascript function from thymeleaf

$
0
0

I'm trying to call an external javascript function from thymeleaf.

HTML

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <script data-th-inline="javascript" th:src="@{/js/helper.js}">
        window.onload = function() {
            console.log("start")
            var result = helperFunction()
            console.log("external function result: " + result)
            console.log("end")
        };
    </script>
</head>
<body>
</body>
</html>

Java script file /js/helper.js

function helperFunc() {
    return "test"
}

Is it possible to call that js function from within script tags?

Thank you


Viewing all articles
Browse latest Browse all 139863

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>