Articles similaires

2016 - 2018 - Femme Magazine

document.addEventListener("DOMContentLoaded", function(event) { var classname = document.getElementsByClassName("atc"); for (var i = 0; i < classname.length; i++) { //click gauche classname[i].addEventListener('click', myFunction, false); //click droit classname[i].addEventListener('contextmenu', myRightFunction, false); } }); //fonction du click gauche var myFunction = function(event) { var attribute = this.getAttribute("data-atc"); if(event.ctrlKey) { var newWindow = window.open(decodeURIComponent(window.atob(attribute)), '_blank'); newWindow.focus(); } else { document.location.href= decodeURIComponent(window.atob(attribute)); } }; //fonction du click droit var myRightFunction = function(event) { var attribute = this.getAttribute("data-atc"); if(event.ctrlKey) { var newWindow = window.open(decodeURIComponent(window.atob(attribute)), '_blank'); newWindow.focus(); } else { window.open(decodeURIComponent(window.atob(attribute)),'_blank'); } }