This is a html page with countdown timer created using Javascript, I would like to convert this to a ascx page for a module. I want to add some more controls to the page as well.
First thing I do is to create a javascript file countdowntimer.js.
Then I need to create a ascx control for a DNN mdoule.
How can I reference asp.net control in the javascript file, such as document.timer.start.value?
How can I start a javascript function when a page is loaded. I tried to use body, but it does not seem to be correct.
Expert help is appreciated.
Thanks
<html>
<head>
<script>
<!-- Begin
var up,down;var min1,sec1;var cmin1,csec1,cmin2,csec2;
function Minutes(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(0,i));
}
function Seconds(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(i+1,data.length));
}
function Display(min,sec) {
var disp;
if(min<=9) disp=" 0";
else disp=" ";
disp+=min+":";
if(sec<=9) disp+="0"+sec;
else disp+=sec;
return(disp);
}
function CountDown() {
cmin2=1*Minutes(document.timer.start.value);
csec2=0+Seconds(document.timer.start.value);
DownRepeat();
}
function DownRepeat() {
csec2--;
if(csec2==-1) {
csec2=59; cmin2--;
}
document.getElementById('display').innerHTML=Display(cmin2,csec2);
if((cmin2==0)&&(csec2==0)) {
window.close();
}
else down=setTimeout("DownRepeat()",1000);
}
function remote(url) {
window.opener.location=url
window.close();
}
DownRepeat();
// End -->
</script>
</head>
<body onLoad="CountDown()">
<form name="timer" align="center">
<input type="hidden" name="start" value="7:00"><p><span id="display"></span>
</form>
</body>
</html>
Kevin Sheng