dimanche 22 mars 2015

Javascript double-click does not work in IE9 and IE11


In my javascript code, single-click opens link in new tab and double-click opens light-box. It works ok in all browsers except in IE9 and IE11. In my first code, both single-click and double-click work but for single-click, IE gives message, "allow pop-up?" I want IE to open the link in new tab w/o the message just like the other browsers. In my second code, single-click works as I want but the second click of double- click in IE gets ignored and ends up working as single-click. Can something be done to remove the issue - either in the first code or in the second code - that I am perhaps missing?


First Code:



$('div[id^="jzl_"].short').click(function(e) {
var $this = $(this);
var currentID = e.target.id;

if ($this.hasClass('clicked')) {
$this.removeClass('clicked');
$.colorbox({
href : "getInfo1.php?id=" + currentID,
overlayClose : false,
top : "16%"
});
//$.colorbox({ overlayClose: false });
//alert("Double click");
//here is your code for double click
} else {
$this.addClass('clicked');
setTimeout(function() {
if ($this.hasClass('clicked')) {
$this.removeClass('clicked');
// alert("Just one click!");
var jobSite = window.open('', '_blank');
sleep(1000);
var redirct = getPage(currentID);
sleep(1000);
jobSite.location = redirct;
//var redirct = getPage(currentID);
//window.open(redirct, '_newtab' + Math.floor(Math.random() * 999999));
}
}, 500);
}
});


Second Code:



$('div[id^="jzl_"].short').click(function(e) {
var $this = $(this);
var currentID = e.target.id;
var jobSite = window.open('', '_blank');
if ($this.hasClass('clicked')) {
$this.removeClass('clicked');
$.colorbox({
href : "getInfo1.php?id=" + currentID,
overlayClose : false,
top : "16%"
});
//$.colorbox({ overlayClose: false });
//alert("Double click");
//here is your code for double click
} else {
$this.addClass('clicked');
setTimeout(function() {
if ($this.hasClass('clicked')) {
$this.removeClass('clicked');
// alert("Just one click!");
var redirct = getPage(currentID);
jobSite.location = redirct;
//var redirct = getPage(currentID);
//window.open(redirct, '_newtab' + Math.floor(Math.random() * 999999));
}
}, 500);
}
});




Aucun commentaire:

Enregistrer un commentaire