Javascript 关于Google扩展的简单初学者问题
所以我是一个初学者,我想创建一个google扩展,我已经解决了所有问题,但是当我在google chrome上打开它时,在一个事件中,它似乎不起作用,按钮根本不起作用,我尝试了很多故障排除。下面是background.js文件中包含onEvent的部分,onEvent对我来说不起作用 Java脚本Javascript 关于Google扩展的简单初学者问题,javascript,google-chrome-extension,Javascript,Google Chrome Extension,所以我是一个初学者,我想创建一个google扩展,我已经解决了所有问题,但是当我在google chrome上打开它时,在一个事件中,它似乎不起作用,按钮根本不起作用,我尝试了很多故障排除。下面是background.js文件中包含onEvent的部分,onEvent对我来说不起作用 Java脚本 // When Profit Button is clicked the program begins, and if a fee is inputed it will calculate with
// When Profit Button is clicked the program begins, and if a fee is inputed it will calculate with the fee. It will also
// calculate the shipping if you input a shipping
onEvent("findProfit", "click", function( ) {
setText("profitText", (getNumber("soldfor")) - getNumber("boughtfor"));
profit = getNumber("profitText");
fee = getText("feeInput");
shipping = getText("shippingInput");
if (fee != "") {
feeMultiplier = 1-(fee * 0.01);
setText("profitText", profit*feeMultiplier);
}
profit = getNumber("profitText");
if (shipping != "") {
setText("profitText", profit-shipping);
}
calculate();
BoughtFunction();
SoldFunction();
ProfitFunction();
updateScreen();
console.log(fee);
});
这个问题并不简单,因为它缺少。到目前为止,我看到了一个大错误:后台脚本运行在隐藏的后台页面(或ManifestV3中的服务工作者)中,因此没有任何单击事件。您可能根本不需要背景脚本,只需在弹出窗口中使用脚本即可。阅读文档中的体系结构,然后找到一个示例扩展并在其上进一步构建。