I am building Login page with Spring boot and thymeleaf. I pass the opcode using model attribute. And I want to use it for th:if to make condition to call javascript function automatically(meaning : without any click). Here is my code under.
<a th:if="${opcode == 1}" th:href="'javascript:setlocation()'"></a>
<script>
function setlocation(){
var msg = alert('Loss of location information found. Turning into setting page...');
location.href='/setlocation';
}
</script>