javascript - How to bind functions to custom buttons in chrome plug-in?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-07-05 10:47:37
0
1
846

RT, there is a chrome plug-in, there is a button in the html page of the plug-in, click the button, how to call the function defined in the plug-in and the js file?

In the index.html page of the plug-in:

<button  onclick='test()'>开始获取</button>

In the main.js file of the plug-in:

function test(){
  console.log('come from test');
}

Link main.js in index.html

//index.html在html文件夹中,注意这里要使用相对路径                                                                 
<script src="../script/main.js" charset="utf-8"></script>

It is not feasible to directly bind the test() function to the button, so how to call it

Supplementary solutions

Right-click on the plug-in, check the plug-in console, and find an error

Be sure to note that the plug-in console and the page console are not in the same place

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
漂亮男人

Have you linked main.js in index.html

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template