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

  • Home
  • SEARCH
  • 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 890681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:46:19+00:00 2026-05-15T13:46:19+00:00

I am creating an extension that will launch an external script based on highlighted

  • 0

I am creating an extension that will launch an external script based on highlighted text. So, far, the script works, except I am having issues closing the newly created window.

In my background.html, I have the following:

<script>
function executeScript(selection) {
  var queryText = 'script:' + selectedText;
  chrome.tabs.create({url: queryText});
  chrome.tabs.getSelected(null, function(tab) {
    chrome.tabs.remove(tab.id);
  });
}
</script>

My problem is with the setup above, it closes the tab before the “url” loads, so it never executes the script.

If I take out the getSelected lines (lines 5-7), it opens the tab and runs the script perfectly. I am trying to just get the syntax to close the tab automatically after it executes.

Thanks!

  • 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-05-15T13:46:20+00:00Added an answer on May 15, 2026 at 1:46 pm

    Not exactly sure what you are trying to accomplish, but if you want to close a tab after a script has run you should have the script send a “Close Me” request to background.html using chrome.extension.sendRequest.

    You might be better off using chrome.tabs.executeScript, which allows you to pass a function (in which you could close the tab) which gets called after the script has finished running.

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

Sidebar

Related Questions

I am creating a Chrome Extension that upon clicking the extension icon will present
I'm creating a Safari extension that will stay in Safari's menubar, and upon being
I'm creating a Chrome extension that uses key bindings (i.e. will use javascript keydown
I am creating a firefox extension that should give a notification when the user
I ran into some trouble while creating a C-Extension for ruby that got me
I am creating a utility that will store data on flat file in a
I am creating a Chrome extension which will send the URL of every page
I'm having issues with creating an AIR file from an Adobe AIR HTML/JavaScript project.
I am creating a TFS tool that will get changeset information from the TFS
I'm new to JASIG CAS and am creating some new pages that will be

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.