Reputation: 325
I have main.js
page where I used mainWindow.loadFile('./app/main.html',options)
to load new file called main.html
Along with it i sent options which stores data in json structure.
How can I receive and use this options
data in main.html page?
using loadFile its loading main.html page . How can we retreive the data sent along?
Upvotes: 3
Views: 906
Reputation: 2474
In your HTML page, you must parse the URL of your window
If you sent these options from your main process
mainWindow.loadFile("./app/main.html"), {
query: { queryKey: "queryValue" },
hash: "hashValue",
});
In your HTML page (renderer process)
console.log(location.href) // YOUR_PATH/app/main.html?queryKey=queryValue#hashValue
console.log(location.search) // ?queryKey=queryValue
console.log(location.hash) // #hashValue
// You'll probably want to use URLSearchParams
const params = new URLSearchParams(location.search)
console.log(params.get("queryKey")) // queryValue
Upvotes: 3