getElementById在popup.js中不起作用[chrome扩展名] [英] getElementById not working in popup.js [chrome extension]
本文介绍了getElementById在popup.js中不起作用[chrome扩展名]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在chrome扩展程序弹出窗口中将null替换为REPLACED
I want to replace the word null with the word REPLACED in my chrome extension popup
我的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>
我的popup.js:
My popup.js:
document.getElementyById("userselect").innerHTML = "REPLACED!";
我从检查弹出窗口中得到的错误消息
The error message I get from inspecting the popup
未捕获的TypeError:document.getElementyById不是函数
在此方面的任何帮助将不胜感激:)
Any help on this would be greatly appreciated :)
推荐答案
有两种错误.一种是 typo
(拼写错误).另一个是包括 JavaScript
位置.
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>
在 popup.js
document.getElementById("userselect").innerHTML ="REPLACED!";
这篇关于getElementById在popup.js中不起作用[chrome扩展名]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文