Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

html context menu

oncontextmenu = (e) => {
  e.preventDefault()
  let menu = document.createElement("div")
  menu.id = "ctxmenu"
  menu.style = `top:${e.pageY-5}px;left:${e.pageX-5}px`
  menu.onmouseleave = () => ctxmenu.outerHTML = ''
  menu.innerHTML = "<p>Option1</p><p>Option2</p><p>Option3</p><p>Option4</p><p onclick='alert(`Thank you!`)'>Upvote</p>"
  document.body.appendChild(menu)
}
Comment

context Menus

const CONTEXT_MENU_ID = "MY_CONTEXT_MENU";
function getword(info,tab) {
  if (info.menuItemId !== CONTEXT_MENU_ID) {
    return;
  }
  console.log("Word " + info.selectionText + " was clicked.");
  chrome.tabs.create({  
    url: "http://www.google.com/search?q=" + info.selectionText
  });
}
chrome.contextMenus.create({
  title: "Search: %s", 
  contexts:["selection"], 
  id: CONTEXT_MENU_ID
});
chrome.contextMenus.onClicked.addListener(getword)
 Run code snippet
Comment

context menus use

function getword(info,tab) {
  console.log("Word " + info.selectionText + " was clicked.");
  chrome.tabs.create({  
    url: "http://www.google.com/search?q=" + info.selectionText
  });
}
chrome.contextMenus.create({
  title: "Search: %s", 
  contexts:["selection"], 
  onclick: getword
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: JSON.parse() error 
Javascript :: how to remove an element from an array javascript 
Javascript :: where from terminal colors come 
Javascript :: custom js shopify 
Javascript :: electron hot reload 
Javascript :: javascripts events 
Javascript :: react native dynamic style 
Javascript :: lottie npm 
Javascript :: js get smallest value of array 
Javascript :: simple website with html css and javascript 
Javascript :: TypeError: error.status is not a function 
Javascript :: find the length and the last character of string in js 
Javascript :: react map list render dictionary 
Javascript :: if page is loading then show loader in js 
Javascript :: mongoose match aggregate 
Javascript :: eliminar duplicados javascript 
Javascript :: how to check if input is valid javascript 
Javascript :: math question 
Javascript :: JavaScript Change the Elements of an Array 
Javascript :: loading button jquery 
Javascript :: unity overlap box 
Javascript :: uploading json data to s3 bucket in node js 
Javascript :: javascript loop array 
Javascript :: Tushar Jadhav 
Python :: pandas show all rows 
Python :: if file exists delete python 
Python :: python alphabet list 
Python :: python selenium get image src 
Python :: install fastapi conda 
Python :: python move file 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =