Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:18:16+00:00 2026-06-03T13:18:16+00:00

I want to get a reference for chrome.contextMenus.create title property in onClick function. For

  • 0

I want to get a reference for chrome.contextMenus.create title property in onClick function.

For example:

chrome.contextMenus.create({"title": "sometitle", "contexts":["selection"], "onclick": searchSelection});

function searchSelection(info, tab){
    var query = "<i want title (sometitle) here>"+info.selectionText;
    var url = "http://www.google.com/search?q="+query;
    chrome.tabs.create({url: url});
}

I searched, but found no option doing this.


+1 Question: is there a way to inline edit contextMenu item? Or append an editable input field after CM element? I think no, but worth for a question 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:18:20+00:00Added an answer on June 3, 2026 at 1:18 pm

    There’s no existing API method to retrieve information about a given menu item, since this information is rarely needed, and already available to the extension’s developer.

    Here’s a general-purpose function to achieve the result:

    /**
     * Creates a menu item using chrome.contextMenus.create.
     * When the second argument is specified, the click handler receives a
     *  third argument: The original creation data.
     * When the "onclick" property is set in the creationData, the "onclick"
     *  event does not receive a third parameter.
     *
     * @param object creationObject    Basic creation object
     * @param function onclickHandler  "click" property of the creationObject
     */
    function createMenuItem(creationObject, onclickHandler) {
        if (onclickHandler) {
            creationObject.onclick = function(onClickData, tab) {
                onclickHandler(onClickData, tab, creationObject);
            };
        }
        return chrome.contextMenus.create(creationObject);
    }
    
    // Usage:
    createMenuItem({"title": "sometitle", "contexts":["selection"]}, searchSelection);
    function searchSelection(info, tab, creationData) {
        var query = "<i want title " + creationData.title + " here>" + info.selectionText;
        var url = "http://www.google.com/search?q=" + query;
        chrome.tabs.create({url: url});
    }
    

    And no, there is no way to add an inline-editable menu item (the only available options are mentioned in the documentation, chrome.contextMenus.create).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the Google Chrome debugger, I often want to get a reference to a
I want to get a reference to the Gmail Inbox button in Javascript? I
I want to hold reference to object so it doesn't get deleted in bind
I want to know how we can get record count using reference cursor in
I want get the time used for a case so I can create an
i want to get a reference from a list of objects on an object
I do not want any code but want to get reference that how can
I want to get a reference to the current solution, using the DTE2 object
I am creating a firefox extension. I want to get a reference to the
In javascript, I can use foo.caller to get a reference to the function above

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.