- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在构建我的第一个 chrome 扩展程序,但遇到了一些问题。我想在 popup.html 上使用 jQuery。弹出窗口否则工作正常,但 jQuery 不起作用。
编辑: 我更改了它,这是新代码,但仍然不起作用。有任何想法吗?我花了两个多小时试图弄清楚。我是扩展的初学者并且对 javascript 和 jquery 很生疏,所以它肯定是一些小而令人尴尬的东西......非常感谢!
list .json
"content_scripts": [{
"matches": [website],
"js": [
"content.js",
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"]
}],
popup.html
<!DOCTYPE html>
<html>
<head>
<title>First Google Extension</title>
<style>
body {
font-family: "Segoe UI";
width: 300px;
font-size: 14px;
};
#changeMe {
color: blue;
font-style: bold;
};
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
Welcome to my first Google Chrome Extension! <br>
<div id="changeMe">
I'm different!
</div>
</body>
</html>
popup.js
$(document).ready(function() {
$("#changeMe").append("Test!");
});
最佳答案
你需要:
学习 debug extension popups .它将向您显示信息性错误。
上述错误将引用内容安全政策。所以你需要阅读 extensions' CSP .
阅读上述文档后,您需要解决的第一个问题是尝试使用远程脚本。这是 possible , 但对于像 jQuery 这样的东西,最好下载它的副本,将它添加到扩展的文件夹并将它作为本地文件包括在内:
<!-- refers to extension's own folder -->
<script src="jquery.min.js"></script>
其次,您需要将自己的脚本收集到一个文件中,并像这样包含在内; inline code is not allowed in any form ,内容脚本不适用于扩展页面。
关于javascript - jQuery 在 chrome 扩展弹出窗口中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33069456/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!