Help us understand the problem. What is going on with this article?

ElectronのBrowserWindowでDOMにアクセスする

More than 3 years have passed since last update.

ドキュメント内に要素があるかどうかで分岐したかった。

let window = new browserWindow({width: 400, height: 400});

window.loadURL('http://localhost:3000/');

window.webContents.on('did-finish-load', function() {
  window.webContents.executeJavaScript('document.querySelector("#dom-id")', function (result) {
    if (result != null) {
      console.log('dom-id見つかったよ');
    }
  }
}
tkiha
sonicgarden
「お客様に無駄遣いをさせない受託開発」と「習慣を変えるソフトウェアのサービス」に取り組んでいるソフトウェア企業
http://www.sonicgarden.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away