好的,
所以我一直在使用 firebug 以及我编写的一些扩展来在我经常使用的网站上创建快捷方式。有件事我不明白为什么它不起作用或为什么它不可能:
示例代码:
<input type="button" onclick="addNewRow()" id="addRow"/>
//This will add a new row to the current table.
//The function is defined by the website (not my function)
使用 Firebug 时:
jQuery("#addRow").click();
//This will simulate the button click, and will automatically add the new row.
使用 Google Chrome 扩展程序时:
jQuery("#addRow").click();
//It doesn't add the new row.
为什么按钮点击后扩展无法执行该函数,而firebug运行却没有问题?
这正常吗?这是一项安全功能吗?还是我做错了什么?
我知道出于安全原因我无法访问网站中的现有功能,但为什么按钮模拟不会为我触发它?
最佳答案
尝试:
jQuery("#addRow").trigger("click");
关于Jquery - 模拟点击按钮不触发功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9620449/