dimanche 1 mars 2015

Progress image loader pure javascript only when click on submit

I'd like to show a progress image loader only when the user clicked on submit... at the moment I can only show a progress image when the user click on submit but the loader image is displayed also when the user reload the page... so I'd like to isolate the event only a clicked button (submit) without having the loader displayed in other ways... so I try to display the image loader only if the user clicked submit button... I provide an example in order to show what I looking for in pure javascript... I hope someone can help me.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="pragma" content="no-cache">
<meta name="robots" content="noindex, nofollow">
<title>BackUp</title>
<link rel="stylesheet" type="text/css" href="backup.css">
<script language="javascript" type="text/javascript">
function StartProgress() {
ProgressImage = document.getElementById('progress_image');
document.getElementById("progress").style.display = "block";
setTimeout("ProgressImage.src = ProgressImage.src", 100);
return true;
}
</script>
</head>

<body onUnload="StartProgress()">

<div class="mainbox">
<div class="box1">
<span class="title">BackUp</span>
</div>
<div class="cleardiv"></div>
<div class="box2">
<form onSubmit="return StartProgress()" action="backup.php" method="post">
<input class="backup_button" type="submit" name="submit" value="BackUp">
</form>
</div>
<div class="cleardiv"></div>
<div style="display: none" id="progress"><img id="progress_image" src="css/busy.gif" alt="BackUp in progress..."></div>
<div class="cleardiv"></div>
</div>

</body>

</html>

Aucun commentaire:

Enregistrer un commentaire