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 6162625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:41:08+00:00 2026-05-23T21:41:08+00:00

I have a bit of a problem here. Based on my previous question asked

  • 0

I have a bit of a problem here. Based on my previous question asked I have developed an extension that takes note of the mouse-clicks and marks the place.

However, when I click on a link to open a pop-up; the mouse-clicks that are marked are on the background window and not on the pop-up.

Is this a security issue or something ?

background.html

chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
    chrome.tabs.captureVisibleTab(null, {format:"png"}, function(dataUrl){

    var img = new Image();
    img.onload = function(){
        var canvas = document.getElementById("canvas");
        canvas.width = img.width;
        canvas.height = img.height;

        var ctx = canvas.getContext("2d");

        ctx.drawImage(img, 0, 0);
        ctx.arc(request.x, request.y, 5, 0, Math.PI*2, true);
        ctx.fillStyle = "rgb(255,0,0)";
        ctx.fill();

        chrome.tabs.create({url: canvas.toDataURL("image/png")});
    };
    img.src = dataUrl;

});
sendResponse({});
});
<body>
    <canvas id="canvas"></canvas>
</body>

content_script.js :

window.addEventListener("click", function(event) {
    chrome.extension.sendRequest({x: event.x, y: event.y});
});
  • 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-23T21:41:08+00:00Added an answer on May 23, 2026 at 9:41 pm

    This happens because current window and focused window are two different things in Chrome API. Passing null to chrome.tabs.captureVisibleTab() takes current window, which for popups means a background window. As it says in the docs:

    The current window is the window that contains the code that is currently executing. It’s important to realize that this can be different from the topmost or focused window.

    To make screenshot of a window that sent the request we need to specify it explicitly:

    chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
        chrome.tabs.captureVisibleTab(sender.tab.windowId, {format:"png"}, function(dataUrl){
            ...
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here's my problem. I have a python script that takes a zipfile and
I'm having a bit of a problem here. We have 2 urls let me
I have a bit of a problem. I wrote an API a long time
I have a bit of a problem with user controls. Basically what I want
I have run in to a bit of a problem and I have done
I'm having a bit of a problem. I have a datatable in the parent
I have run into a bit of a tricky problem in some C++ code,
Ok - a bit of a mouthful. So the problem I have is this
I have a bit of code that basically reads an XML document using the
I have a bit of a problem. I have a java application and when

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.