I save the position of a window when it’s closed:
const savePositionToStorage = (position) => {
localStorage.setItem('windowPosition', position);
console.log('Position saved:', position);
}
const getPositionFromStorage = () => {
const position = localStorage.getItem('windowPosition');
return position ? position : "top=0,left=0,width=800,height=1000";
}
and open a window like this:
const handleExpandClick = (id) => {
const windowFeatures = getPositionFromStorage();
const pdfWindow = window.open(
`http://127.0.0.1:8000/transactions/matching_evidence/${id}#toolbar=0,view=FitH`,
"pdf",
windowFeatures,
);
pdfWindow.onload = () => {
pdfWindow.onbeforeunload = () => {
savePositionToStorage(`top=${pdfWindow.screenY},left=${pdfWindow.screenX},height=${pdfWindow.innerHeight},width=${pdfWindow.innerWidth}`)
}
}
}
The user should be able to save the current location and size of the window, so the user doesn’t have to readjust the pop-up every time.
It works with the current browser monitor, but if I close it on another monitor, it will simply pop up on the furthest right of the current browser monitor.
Is there a way to archive what I want?
Chrome would be the browser the users are using.