<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="Tokyo" class="tabcontent"> <br> <a href="file:///C:/xampp/htdocs/final/pop.html" class="a-tag" target="popup" onclick="window.open('file:///C:/xampp/htdocs/final/pop.html','popup',`width=600,height=400,top=${window.outerHeight/2 - 250},left=${window.outerWidth/2 - 300}`); return false;"> Click to Upload Files </a> </div> </body> </html>Cuando hago clic en clic para cargar archivos, aparece una ventana emergente.
Aquí está mi ventana emergente:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <input type="file" multiple> </body> </html>Quiero actualizar mi pantalla con la etiqueta de clic para cargar archivos, cada vez que cierre mi ventana emergente. ¿Cómo lograr esto? Gracias.
Puedes hacerlo:
window.location.reload();o puede usar window.location.href, este método vuelve a cargar la página. así que también puedes hacer esto:
window.location.href = window.location.pathname + window.location.search + window.location.hash;El OP quería una forma de identificar cuándo se cerró la ventana emergente antes de actualizar la página.
Puede asignar la ventana emergente a una variable y luego usar el evento window.onbeforeunload para determinar cuándo se cierra la ventana emergente.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="Tokyo" class="tabcontent"> <br> <a href="file:///C:/xampp/htdocs/final/pop.html" class="a-tag" target="popup" onclick="onUserUpload()"> Click to Upload Files </a> </div> </body> </html> function onUserUpload(e) { let popup = window.open( 'file:///C:/xampp/htdocs/final/pop.html', 'popup', `width=600,height=400,top=${window.outerHeight/2 - 250},left=${window.outerWidth/2 - 300}` ); popup.addEventListner('beforeunload', function refreshOnClose(e) { //the event only fires after the popup window is closed if(Object.keys(e).length) { console.log('Popup is closed.'); popup.removeEventListener('beforeunload', refreshOnClose); //reload current window return window.location.reload(); } } })window.reload() <form onsubmit="window.reload()"> <input type="file" multiple /> </form>