I don't understand how this can't be working. It has been tested OK in FireFox. This is my code:

Code:
 <script>
 function closeWin()
{
var location = document.getElementById("searchbox").value;   //TextField
    
    localStorage.setItem("routeName", location);	
	
window.close();
}

<button onclick="closeWin()">Välj</button>

 </script>
Why isn't it working?