LoginSignup
2
3

More than 5 years have passed since last update.

Electronでrenderer.jsで定義したfunctionをindex.htmlから呼び出せるようにする

Posted at

とりあえずこうしたら動くよ程度なので、ベスプラ教えてください。。

renderer.js
function hoge() {
  console.log('hoge');
}

これを

index.html
<button onclick="hoge()">hoge()</button>

としても動きません。

一つの直し方として、hoge関数をwindowオブジェクトに登録したらうまく行きました。

renderer.js
function hoge() {
  console.log('hoge');
}

window.hoge = hoge;
2
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3