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 :: wrapping a span tag with an a tag with a href target same as the text of the span 
Javascript :: What is the best way to download mulitple images using jquery 
Javascript :: How to check the increase/decrease of letter input in pasting clipboard in jQuery 
Javascript :: javascript is nodelist 
Javascript :: js generate pnh 
Javascript :: How to change a key value pair within a nested json structure C# 
Javascript :: PAN SNAP 
Javascript :: string split into three non empty combination js 
Javascript :: image react not showing 
Javascript :: promsie js 
Javascript :: morgan tiny 
Javascript :: cleave js 
Javascript :: assign single value to multiple variables in React js Or javacript 
Javascript :: Uncaught (in promise) TypeError: dispatch is not a function 
Javascript :: phaser rotate matrix 180 
Javascript :: 120. Triangle - JavaScript Solution With Explantion 
Javascript :: Another Bind() Example 
Javascript :: difference between push and pop in javascript 
Javascript :: querySelectorAll select multiple element types 
Javascript :: push replacement getx 
Javascript :: convert .js to .ts 
Javascript :: add text to each element in an array javascript 
Javascript :: todo app html css javascript 
Javascript :: winston transport file another directory 
Javascript :: JavaScript is synchronous by default 
Javascript :: Populate a Select Dropdown List using JSON 
Javascript :: Solution-4-C--solution options for reverse bits algorithm js 
Javascript :: responsive navbar react 
Javascript :: or js 
Javascript :: find an element 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =