I have this in my HTML body:
<script src="{% static "jquery/sessionExists.js" %}"></script>
{% if context.alreadyOnSession == 'YES' %}
<h5 class="loginerror" onload="advSessionExists()">This session is already logged in</h5>
{% endif %}
These {}
are django code.
sessionExists.js:
function advSessionExists(){
console.log('Just checking if its triggered');
}
Also I tried by putting my JavaScript code raw in the HTML body with <script type=text/javascript></script>
, and also I tried with onbeforeprint
instead of onload
but it is still not showing my JS method.
The <h5> is being showed
, but not triggering my JS method.