eliminar archivo al cerrar pestaña o navegador ¿es posible?
Publicado por Ruben (25 intervenciones) el 25/10/2021 09:17:13
Buenas...
Es posible borrar un archivo en el momento que se cierra una pestaña o se cierra el navegador (No cuando se refresca)..
Buscando en la red he encontrado este codigo pero no se adaptarlo (estoy pez en codigo java, php y html) ...
Mi otro problemas es que el archivo que se borra no es siempre tiene el mismo nombre, varia en función de una variable php utilizada en la pagina.
Me pueden ayudar... Gracias.
Es posible borrar un archivo en el momento que se cierra una pestaña o se cierra el navegador (No cuando se refresca)..
Buscando en la red he encontrado este codigo pero no se adaptarlo (estoy pez en codigo java, php y html) ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
var validNavigation = false;
function wireUpEvents() {
var dont_confirm_leave = 0; //set dont_confirm_leave to 1 when you want the user to be able to leave withou confirmation
var leave_message = 'ServerThemes.Net Recommend BEST WEB HOSTING at new tab window. Good things will come to you'
function goodbye(e) {
if (!validNavigation) {
window.open("http://serverthemes.net/best-web-hosting-services","_blank");
return leave_message;
}
}
window.onbeforeunload=goodbye;
// Attach the event keypress to exclude the F5 refresh
$(document).bind('keypress', function(e) {
if (e.keyCode == 116){
validNavigation = true;
}
});
// Attach the event click for all links in the page
$("a").bind("click", function() {
validNavigation = true;
});
// Attach the event submit for all forms in the page
$("form").bind("submit", function() {
validNavigation = true;
});
// Attach the event click for all inputs in the page
$("input[type=submit]").bind("click", function() {
validNavigation = true;
});
}
// Wire up the events as soon as the DOM tree is ready
$(document).ready(function() {
wireUpEvents();
});
</script>
Mi otro problemas es que el archivo que se borra no es siempre tiene el mismo nombre, varia en función de una variable php utilizada en la pagina.
Me pueden ayudar... Gracias.
Valora esta pregunta


0