Here is what I'm trying to do:
when the user signs up I store the current window in a variable and I send him an email:
<script>sessionStorage.setItem("window", window)</script> <?php sendEmail(/*...*/); ?>
when the user opens the email, I get the previously saved window from the storage and close it
<script>sessionStorage.getItem("window").close()<script>
This would prevent the browser from having too much unuseful windows opened on the same domain.
The problem is that I get an error like this:
Uncaught TypeError: sessionStorage.getItem(...).close is not a function
(same result if I previously store it on variable)
Furthermore, when I log the current window I get an object containing every method:
Window {parent: Window, opener: null, top: Window, length: 0, frames: Window, …}
alert: ƒ alert()
...
when I log the stored function I just get this:
[object Window]
Is there a way to achieve my goal?
Is it possible to pass a window as a simple variable?
Am I doing something wrong?