javascript - 如何从电子 BrowserWindow 对象获取当前 URL?
问题描述
我想知道browser-window的当前 URL 。有没有办法访问 BrowserWindow 的 window.location.href 属性或任何其他方式来获取它?
解决方案
在主进程中,使用窗口的 webContents。getURL()方法:
[...]
win = new BrowserWindow({ /* options */});
win.loadFile('index.html');
console.log (win.webContents.getURL();)
推荐阅读
- c++ - C ++中的意外无限循环
- android - 我可以在 Kotlin 中使用 MutableLiveData 直接实例化用户对象吗?
- asp.net - 如何在sql参数列表中使用forloop?
- javascript - 如何知道浏览器限制了第 3 方图像的显示?
- flutter - 无法识别样式参数
- python - 在python中识别子和父组合组
- asp.net-core - 如何通过 DI 将经过身份验证的用户 ID 传递给 asp.net 核心中的类库项目?
- git - 无法重写分支:您有未暂存的更改
- php - 将 JSON 数据从视图中的 JavaScript 传递到 laravel 中的控制器
- python - 如何在没有 NumPy 的情况下将矩阵的行转换为 Python 中的列?