I have a page where I am opening a window to perform a ping and then returning those results to the page the user is presently on. This action is performed through a combination of JavaScript and ColdFusion. While, the actual method of pinging and returning the results to the screen works just fine there is a potential problem with users who might become "happy clickers." If a user clicks a checkbox and then clicks another checkbox too quickly the second checkbox will override the window opening for the first checkbox. I have provided a Check All option which alleviates some of the potential for this problem but I would like to create a more programmatic workaround.
I have attempted to write a pause function which works but creates a bad user experience as the page seems to just sit there before moving forward. Ideally I'd like to dynamically create a different window if one is already open.
Ping Function
Pause Function
I have attempted to write a pause function which works but creates a bad user experience as the page seems to just sit there before moving forward. Ideally I'd like to dynamically create a different window if one is already open.
Ping Function
Code:
function ping(checkbox_key,ipAddress)
{
if(typeof pingWindow != "undefined")
{
if (typeof pingWindow.name != "undefined")
pause(2000);
}
pingWindow = window.open("","pingWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=1,height=1,top=0,left=0");
pingWindow.blur();
pingWindow.creator = self;
pingWindow.location.href = "#templatepath#/scanme_ping.cfm?checkbox_key=" + checkbox_key + "&ipaddress=" + ipAddress;
return;
}
Pause Function
Code:
function pause(millis)
{
date = new Date();
var curDate = null;
do {
var curDate = new Date();
}
while(curDate-date < millis);
}