Due to Safari (7.0.1 / Mac OS), I'm struggling with a simple Javascript problem. I submit a form, and I want to display an icon during the page loading.
From what I can see, it's not related to the javascript itself, but more to the onsubmit behavior (if I move it outside the function, it does the expected job when loading the page instead of at "submit" time).
This is my code (working perfectly on Chrome and Firefox). Any idea?
<html>
<body>
<img id="loadingImage" src="assets/images/loadingIcon.png" style="display:none;"/>
<form method="POST" action="js.php" onsubmit="loadLoader()">
<input type="submit" value="Go"/>
</form>
<script type="text/javascript">
function loadLoader(){
document.getElementById('loadingImage').style.display = 'block';
return true;
}
</script>
</body>
</html>
onsubmit
event and instead call loadLoader() in anonclick
event on the input. maybeonclick
is more supported by all browsers, and logically results in the form being submitted? – Esposito