I'm trying to open a street view floating window with "window.open" and then close with "close()". I try with google.com, and it works (the window close). But, with the street view window, doesn't work (don't close). If I open and close immediately it works. I think it's because of redirection. ¿Any ideas to solve?
I have tried it on https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default_default
<!DOCTYPE html>
<html>
<body>
<h1>Google</h1>
<button onclick="openGoogle()">Open "google"</button>
<button onclick="closeGoogle()">Close "google"</button>
<br>
<h1>StreetView</h1>
<button onclick="openStreetView()">Open "streetview"</button>
<button onclick="closeStreetView()">Close "streetview"</button>
<script>
let google;
let streetview;
function openGoogle() {
google = window.open("https://www.google.com/", "Google", "width=800,height=800");
}
function closeGoogle() {
google.close();
}
function openStreetView() {
streetview = window.open("https://www.google.com/maps/@43.3396007,-1.8096601,3a,75y,90t/data=!3m6!1e1!3m4!1sZ81gym2y_KL-MPWdBQ1Mqg!2e0!7i16384!8i8192", "Google", "width=800,height=800");
}
function closeStreetView() {
streetview.close();
}
</script>
</body>
</html>