← Desenvolvimento

[ Dúvida ] - JavaScript

Lida 1578 vezes

Offline

PT-NGS- 
Membro
Mensagens 90 Gostos 0
Troféus totais: 22
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 4 Level 3 Level 2 Level 1 50 Posts 10 Posts

Boas..

Eu estou a usar este script numa página.
mas eu quero colocar quando fechar a página, e não ao abrir a página!..
Alguém pode-me dar uma dica, sff..

Código: [Seleccione]
<SCRIPT language=Javascript>
<!--

if(!window.confirm ("TEXTO\n\nTEXTO.\nTEXTO\n\n- TEXTO;\n- TEXTO;\n- TEXTO;"))
  {
    document.open("http://www.google.com","_self","");
  }
 //-->
</SCRIPT>
Offline

jpgmn 
Membro
Mensagens 305 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

Substitui

Código: [Seleccione]
document.open("http://www.google.com","_self","");

por

Código: [Seleccione]
window.open("http://www.google.com","_self","");

e coloca no evento OnUnload da página.
Offline

PT-NGS- 
Membro
Mensagens 90 Gostos 0
Troféus totais: 22
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 4 Level 3 Level 2 Level 1 50 Posts 10 Posts

Boas..

Será algo assim:

Código: [Seleccione]
<SCRIPT FOR=window EVENT=onunload>
    <!--

if(!window.confirm ("TEXTO\n\nTEXTO.\nTEXTO\n\n- TEXTO;\n- TEXTO;\n- TEXTO;"))
  {
    window.open("http://www.google.com","_self","");
  }
 //-->
</SCRIPT>


Obrigado jpgmn  :wink:  :wink: