我该如何定义电子文件?

问题描述 投票:0回答:1

我发现的其他stackoverflow问题没有帮助我,所以我问你。如何在电子中的html / javascript中定义文档。有错误:“未定义文档”。

html代码:

  <div id="container">
      <div id="left_panel"> left content! </div>
      <div id="right_panel">
          <div id="drag"></div> right content!
      </div>
  </div>

javascript:

const {app, BrowserWindow, Menu} = require('electron');
const url = require('url');
Menu.setApplicationMenu(false);
var isResizing = false;
var lastDownX = 0;

function boot() {
  win = new BrowserWindow({
    'minHeight': 300,
    'minWidth': 300
  })
  win.loadURL(url.format({
    pathname: 'index.html',
    slashes: true
  }))
}

app.on('ready', boot);

(function() {
    var container = document.getElementById("container"),
        left = document.getElementById("left_panel"),
        right = document.getElementById("right_panel"),
        handle = document.getElementById("drag");

    handle.onmousedown = function(e) {
        isResizing = true;
        lastDownX = e.clientX;
    };

    document.onmousemove = function(e) {
        // we don't want to do anything if we aren't resizing.
        if (!isResizing) {
            return;
        }

        var offsetRight = container.clientWidth - (e.clientX - container.offsetLeft);

        left.style.right = offsetRight + "px"; 
        right.style.width = offsetRight + "px"; 
    }

    document.onmouseup = function(e) {
        // stop resizing
        isResizing = false;
    }
})();

如果我得到帮助,那就太好了。谢谢

javascript html dom electron
1个回答
0
投票

executeJavascript方法也许可以在这里为您提供帮助。这使您可以访问文档对象。它返回一个Promise,因此您必须从中拉出Elements。

© www.soinside.com 2019 - 2024. All rights reserved.