久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何獲取 BrowserWindow 的 url?

How to get the url of the BrowserWindow?(如何獲取 BrowserWindow 的 url?)
本文介紹了如何獲取 BrowserWindow 的 url?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

這是一個非常基本的問題.在電子中,如何檢查 BrowserWindow 的 url/文件名?

This is a pretty basic question. In electron, how do I check the url/filename of a BrowserWindow?

let win;

app.on('ready', () => {
    win = new BrowserWindow();

    win.loadFile(path.join(__dirname, 'public', 'main.html'));

    win.on('closed', () => {
        app.quit();
    })
});

好吧,這么說,這是代碼,說在不同的(添加:插入)瀏覽器窗口中發生某個事件后,我想從主瀏覽器窗口(win)獲取 url.

Ok, so say, this is the code, say after a certain event happens in a different (add:insert) BrowserWindow, I want to get the url from the main BrowserWindow (win).

let addWin;

ipcMain.on('createAddWin', ()=>{

    addWin = new BrowserWindow();

    addWin.loadFile(path.join(__dirname, 'public', 'add.html'));

    addWin.on('closed', () => {
        addWin = null
    });

ipcMain.on('add:insert', (e,insertObject) => {
//some event happens
//retrieve url from main window (win)
});

}); 

我該怎么做呢,我寧愿不必向 win 發送事件,然后通過 ipcRenderer 發送 url,盡管這絕對是可能的.

How do I go about this, I prefer to not have to send an event to the win to then send the url through ipcRenderer, though this is definitely possible.

推薦答案

可以使用 getURL() 窗口的 webContents 實例方法> 實例屬性:

Getting the window's URL is possible by using the getURL() instance method of the window's webContents instance property:

let currentURL = win.webContents.getURL();

這篇關于如何獲取 BrowserWindow 的 url?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 亚洲精品乱码久久久久久按摩观 | 91高清视频| 在线观看视频91 | 久久精品1 | 国产精品久久 | 综合九九 | 国产精品毛片av一区 | 国产一区www| 欧美在线视频a | 国产农村妇女毛片精品久久麻豆 | 人人射人人草 | 国产精品区二区三区日本 | 在线观看成人 | 成人影音| 91精品国产91久久久久久最新 | 久久成人在线视频 | 日本中文字幕在线观看 | 一区二区视频 | 激情视频一区 | 一级黄a视频 | 亚洲色图在线观看 | 天天操夜夜操免费视频 | 中文字幕一区二区三区不卡 | 99视频在线 | 国产精品国产成人国产三级 | 91免费在线 | 日本淫视频 | 久久久久免费精品国产 | 亚洲日本中文字幕在线 | 神马久久久久久久久久 | 毛片入口 | 狠狠干2020| 本地毛片 | 伊人久久大香线 | 天天操夜夜操 | 久久综合香蕉 | 91久色 | 日韩国产精品一区二区三区 | 国产专区免费 | 国产亚洲一区二区精品 | 日本啊v在线 |