OSDN Git Service

update the dispatch method
[bytom/Byone.git] / dapp-example / index.html
1 <!DOCTYPE html>
2 <html>
3   <head>
4     <title>bytom-chrome-extension-test</title>
5   </head>
6   <body>
7     <input type="text" id="to" name="to" placeholder="to address" />
8     <input type="number" id="amount" name="amount" placeholder="amount" />
9     <a id="transferButton" href="#">transfer</a>
10
11     <script type="text/javascript">
12       var getById = function(id) {
13         return document.getElementById(id)
14       }
15
16       var bytom
17       getById('transferButton').addEventListener('click', () => {
18         bytom.transfer(getById('to').value, getById('amount').value).then(
19           resp =>{
20             console.log(resp)
21           }
22         )
23       })
24
25       // 监听Bytom插件加载成功事件
26       document.addEventListener('bytomLoaded', () => {
27         console.log('bytomLoaded')
28         bytom = window.bytom
29       })
30     </script>
31   </body>
32 </html>