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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:22:28+00:00 2026-05-29T08:22:28+00:00

I am writing a Chrome extension where I am trying to create a GUI

  • 0

I am writing a Chrome extension where I am trying to create a GUI on top of an existing page. This GUI consists of an input text field, and a reply button. I have created the GUI by creating an HTML string, and appending it to the website.

I want to add an event listener so that when the reply button is pressed, it will trigger a function so I can send the data in the input text field to my server. From my understanding, once code has been appended to the page, it no longer has access to script.js therefore it cannot access an event listener. Is there an alternative?

Image of my GUI: http://www.filedump.net/index.php?pic=eventlistenermoot1328028688.jpg

  • 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-29T08:22:29+00:00Added an answer on May 29, 2026 at 8:22 am

    The page you are injecting code into is sandboxed from content scripts. However your content scripts have full access to the page DOM, including events. That means that you can add an event listener to elements that you append. You have to add them unobtrusively so that the content script can then send a message to the background page:

    Content Script:

    var html = document.createElement('div');
        html.innerHTML = '<input id="clickMe" type="button" value="Click Me" />';
    document.body.appendChild(html);
    
    document.getElementById('clickMe').addEventListener('click', function() {
        // do stuff
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing text to a page using document.write for a Chrome extension, but the
I'm writing a Google Chrome extension which manipulates the current page (basically adds a
I am writing a Google Chrome Extension and trying to make the transition to
I am writing an page action extension for Google Chrome. The extension injects the
I'm writing a Chrome extension, in my background.html page, it is injecting a js
I'm trying to learn JavaScript by writing a Google Chrome extension for Reddit so
im writing a chrome extension and need a simple text editor component so that
I'm writing a chrome extension where the standard popup page is used as a
I'm writing a Google Chrome extension that finds all titles on pages like this
I'm writing a chrome extension that fiddles around with the layout of a page.

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.