0

The objective of this extention is that I can type something into my extention, press submit and and alert to show up with my input.

In my popup.html:

<form id="form" onsubmit="return false;">
  <input  type="text" id="userInput" />
  <input  type="submit" onclick="othername();" />
</form>

manifest.json:

    {
"matches": [
  "<all_urls>"
],
"js": ["content.js"]
},

and the content.js:

alert("test");
function othername() {
var input = document.getElementById("userInput").value;
alert(input);
};

The "test" alert shows up, so I know he code is running, but when I type in a value and press submit, I do not get a popup. Any help would be much appreciated.

Jacob Proctor
  • 27
  • 1
  • 6

1 Answers1

1

You cannot call a function from HTML. Try adding an click event listener in your JavaScript.

document.getElementById('clickbutton').addEventListener('click', function() {
alert('hello ' + document.getElementById("userInput").value);
});

I just created a new Chrome Extension with this purpose. Check it out:
https://github.com/aldi/alert-input-chrome-extension

aldi
  • 718
  • 1
  • 8
  • 22