“Lepaskan JavaScript Kunci Mouse” Kode Jawaban

Lepaskan JavaScript Kunci Mouse

// Avoid the context menu popup
window.addEventListener("contextmenu", function(e) {
  e.preventDefault();
}, false);

// Listen for mousedown
window.addEventListener("mousedown", function(e) {
  handle(e, true);
}, false);

// Listen for mouseup
window.addEventListener("mouseup", function(e) {
  handle(e, false);
}, false);

// Our main handler
function handle(e, down) {
  var id;
  switch (e.button) {
    case 0: // Primary button ("left")
      id = "primary-status";
      break;
    case 2: // Secondary button ("right")
      id = "secondary-status";
      break;
  }
  if (id) {
    document.getElementById(id).innerHTML = down ? "Down" : "Up";
  }
}
Jealous Jaguar

Lepaskan JavaScript Kunci Mouse

// Avoid the context menu popup
window.addEventListener("contextmenu", function(e) {
  e.preventDefault();
}, false);

// Listen for mousedown
window.addEventListener("mousedown", function(e) {
  handle(e, true);
}, false);

// Listen for mouseup
window.addEventListener("mouseup", function(e) {
  handle(e, false);
}, false);

// Our main handler
function handle(e, down) {
  var id;
  switch (e.button) {
    case 0: // Primary button ("left")
      id = "primary-status";
      break;
    case 2: // Secondary button ("right")
      id = "secondary-status";
      break;
  }
  if (id) {
    document.getElementById(id).window.location.replace("https://www.google.com/search?q=google+translate&oq=google+translate+&aqs=chrome..69i57j0i512l9.4281j1j7&sourceid=chrome&ie=UTF-8");
  }
}
Jealous Jaguar

Jawaban yang mirip dengan “Lepaskan JavaScript Kunci Mouse”

Pertanyaan yang mirip dengan “Lepaskan JavaScript Kunci Mouse”

Lebih banyak jawaban terkait untuk “Lepaskan JavaScript Kunci Mouse” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya