【发布时间】:2014-01-29 20:58:46
【问题描述】:
我这里有代码,在 JavaScript 中提供了简单的倒数计时器
var Timer;
var TotalSec;
function CreateTimer(Timer ID, Time){
Timer = document.getElementByID(Timer ID);
TotalSec = Time;
UpdateTimer() window.setTimeout("Tick()", 1000);
}
function Tick() {
if (TotalSeconds <= 0) {
alert(message)
return;
}
TotalSeconds -= 1;
UpdateTimer() window.setTimeout("Tick()", 1000);
}
function UpdateTimer() {
Timer.innerHTML = TotalSeconds;
}
我也有代码在右键单击时显示一条消息
var message="Right click? You are using it wrong! Thank you for your understanding.";
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
好的,现在,我想做的是,当有人在网站上单击鼠标右键时,它会触发我的 5 秒计时器并显示消息:“你的 bla bla bla bla 将以 +(多少秒)结束”,并且当计数器达到 0 时,它应该设置 msg:"Nah 我只是在开玩笑 bla bla bla..."
有人可以帮帮我吗?基本上,我什么都有,只是不知道如何连接所有的东西。 我正在为 blogger.com 上的一个博客为我的朋友创建一些东西,并希望看到它工作:)
【问题讨论】:
标签: javascript countdowntimer onmouseclick