# Browser Tabs

**URL:** <https://discourse.mozilla.org/t/browser-tabs/75139>\
**Category:** Development\
**Created:** [February 7, 2021, 3:55pm UTC](https://discourse.mozilla.org/t/browser-tabs/75139 "2021-02-07T15:55:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian0012](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Adrian0012](https://discourse.mozilla.org/u/Adrian0012)\
**Post date:** [February 7, 2021, 3:55pm UTC](https://discourse.mozilla.org/t/browser-tabs/75139/1 "2021-02-07T15:55:32Z")

</div>

I have created an `browser.menus.onClicked.addListener` and when I click it I runs `browser.tabs.create({url: "context_menu_add_item.html"});`

How can I pass data over to the new tab? Basically I want to pass over selected text.  
Any help would be greatly appreciated?

---

<div class="post-metadata">

**Author:** ![jscher2000](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/jscher2000/32/28202_2.png) [@jscher2000](https://discourse.mozilla.org/u/jscher2000)\
**Post date:** [February 7, 2021, 4:42pm UTC](https://discourse.mozilla.org/t/browser-tabs/75139/2 "2021-02-07T16:42:35Z")

</div>

The new tab is an extension page?

I assume the selected text is too unpredictable to add to the URL (e.g., page.html#selectedText) and access using location.hash.

What I generally do is have the new page request data from the background page during loading or retrieve it from storage.

In your onClicked event handler, you can save menuInfo.selectionText in a global variable or in local storage.

I’m not a professional developer, so what I do isn’t necessarily the best thing to do!
