Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to replace the word null with the word REPLACED in my chrome extension popup

My HTML

<!DOCTYPE html>

<html>
  <head>
    <script src="popup.js" type="text/javascript"></script>
  </head>

  <body>
    <h1> Wordnik Lookup </h1>
    <p id = "userselect">null</p>

  </body>
</html>

My popup.js:

document.getElementyById("userselect").innerHTML = "REPLACED!";

The error message I get from inspecting the popup

Uncaught TypeError: document.getElementyById is not a function

Any help on this would be greatly appreciated :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
453 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is two kind of error. One is typo (spelling mistake). Another is including JavaScript position.

<html>
  <head>

  </head>

  <body>
    <h1> Wordnik Lookup </h1>
    <p id = "userselect">null</p>

     <!--- Kep JavaScript at end. Otherwise listen for DOMContentloaded event --->
     <script src="popup.js" type="text/javascript"></script>
  </body>
</html>

Inside of popup.js

document.getElementById("userselect").innerHTML = "REPLACED!";


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...