[英]How can I change BrowserWindow hash url without reloading the page
I'm loading a page in ElectronJS with BrowserWindow.loadURL("http://google.com")
. 我正在使用BrowserWindow.loadURL("http://google.com")
在ElectronJS中加载页面。 Later on in my application, I need to update the the url by some hash values like http://google.com/#start
and I want it to be done without reloading the page as it's the expected behavior. 稍后在我的应用程序中,我需要通过一些哈希值(例如http://google.com/#start
来更新url,并且希望这样做而无需重新加载页面,因为这是预期的行为。
Using location.assign('#start');
使用location.assign('#start');
works for me inside a local URL. 在本地URL中为我工作。
You may want to try something like this (untested) from the main process: 您可能要在主要过程中尝试以下操作(未经测试):
let window = new BrowserWindow(/*...*/);
window.loadURL("http://google.com");
//
window.webContents.executeJavaScript("location.assign('#start');");
References: 参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.