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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:05:39+00:00 2026-05-24T05:05:39+00:00

I am writing a Google extension. Here my content script modifies a page based

  • 0

I am writing a Google extension. Here my content script modifies a page based on a list of keywords requested from background. But the new innerHTML does not show up on the screen. I’ve kluged it with an alert so I can see the keywords before deciding to actually send a message, but it is not how the routine should work. Here’s the code:

// MESSAGE.JS //
//alert("Message Page");

var keyWordList= new Array();
var firstMessage="Hello!";
var contentMessage=document.getElementById("message");
contentMessage.value=firstMessage;
var msgComments=document.getElementsByClassName("comment");
msgComments[1].value="Hello Worlds!";//marker to see what happens

chrome.extension.sendRequest({cmd: "sendKeyWords"}, function(response) {
    keyWordList=response.keyWordsFound;
    //alert(keyWordList.length+" key words.");//did we get any keywords back?
    var keyWords="";
    for (var i = 0; i<keyWordList.length; ++i)
    {
        keyWords=keyWords+" "+keyWordList[i];
    }
    //alert (keyWords);//let's see what we got
    document.getElementsByClassName("comment")[1].firstChild.innerHTML=keyWords;
    alert (document.getElementsByClassName("comment")[1].firstChild.innerHTML);// this is a band aid - keyWords does not show up in tab
});

document.onclick= function(event) {
   //only one button to click in page
    document.onload=self.close();
};

What do I have to do so that the text area that is modified actually appears in the tab?

  • 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-24T05:05:41+00:00Added an answer on May 24, 2026 at 5:05 am

    (Answering my own question) This problem really has two parts. The simplest part is that I was trying to modify a text node by setting its value like this:

    msgComments1.value=”Hello Worlds!”; //marker to see what happens

    To make it work, simply set the innerHTML to a string value like this:

    msgComment1.innerHTML=”Hello Worlds!”; //now it works.

    The second part of the problem is that the asynchronous call to chrome.extension.sendRequest requires a callback to update the innerHTML when the reply is received. I posted a question in this regard earlier and have answered it myself after finding a solution in an previous post by @serg.

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

Sidebar

Related Questions

I am writing an extension for Google Chrome. The content script never sees that
To learn JavaScript I am writing a small text editor Google Chrome extension. But
I am writing a Google Chrome extension. Thanks to everyone here for putting up
I am writing an page action extension for Google Chrome. The extension injects the
Here's my predicament. I am writing an extension for Google Chrome. And it works
I'm writing an extension for the Yii framework which I have asked on here
I'm writing a Google Chrome extension that needs to do a lot of things
Is it possible to access Google Chrome's cache from within an extension? I'd like
I am writing a code using Google-Ajax-Feed-API to get latest feeds from some site.
I am writing a Google Chrome extension with the help of Google closure compiler.

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.