In my electron application, I have a frameless window which is created once i click a button. A new html template is loaded in. This is then the new window which is being focussed on.
When i click on one of the buttons within this window I want to alter the appearance of some of the elements that are within the index.html.
My question is how would I be able to put the focus on both of the browser windows, or is there a way to load in the elements (Ids and classes) of the index.html page so i can have easy access to them in my JS file?
Iāve tried to do something like below, but this didnāt work.
Hey thanks for the reply!, iām just a bit confused about the pageNr - how would i then use the pageId variable to reference the individual Id elements? apologies as im pretty new to javascript.
for example i would like to access a div element in my sidebar.html file with an id of ānotready-reasonsā. This is so that when when click on a button in my index.html file i can then generate the animation when the new browser window opens. See function below:
The document.setItemById(āpageNrā) should be document.getItemById(āpageNrā)
In my work, as I am using ādocument.getItemById()ā quite often I have a function"
const $id = id => document.getItemById(id);
Saves a lot of typing.
But back to your query
First I have never used templates I use one html file for everything, just change the content using js. I also develop for Chrome only as I use elements, like dialog, that are only fully supported by Chrome.
So when you talk about changing pages and using templates, I can only guess what you are referring to.
However
In your click event handler you can use the localStorage.setItem(identifier) to store whatever text you desire.
Then when in the new page you can use: let identifier = localStorage.getItem(identifier) to retrieve it in the new page.