Oprire utilizator cu confirmare la parasire pagina

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
LCristian
Mesaje: 12

Oprire utilizator cu confirmare la parasire pagina

Slaut, am putina nevoie de ajutor, la ultimul "pas" al votului, clientul trebuia sa introduca codul captcha intr-un iframe dupa care de pe site-ul meu este redirectionat catre "top-ul" respectiv.(ex: xtremetop).
Am explicat cam aiurea. O poza sa fie ceva mai clar.
Imagine

Cum as putea face a.i clientul sa nu fie "lasat" sa paraseasca pagina decat dupa ce votul este validat de catre "iframe" si pagina din el este redirectionata catre "top".

Multumesc :)

MarPlo Mesaje: 4343
Salut
Cred ca se poate daca poti adauga cod in fisierul din iframe, adica o instructiune javascript care, atunci cand e adaugat votul, sa acceseze o functie din pagina parinte, folosind: parent.numeFunctie() (care de exemplu sa adauge un DIV transparent pe toata fereastra), iar dupa validare sa apeleze alta functie ca sa stearga acel DIV, si imediad face redirect.
Dar asta presupune sa ai access la codul paginii din iframe.

LCristian Mesaje: 12
Nu am cum sa am acces la iframe. Totusi am vazut chestia asta la un alt site.
M`am uitat in sursa paginii lor si am luat asta: infusionconquer.com/insanity/code.txt

MarPlo Mesaje: 4343
M-am uitat putin pe acel cod. Nu am inteles cine stie ce, dar poate functioneaza adaugand acest cod in pagina.

Cod: Selectaţi tot

<style><!--
body{
padding:0;
margin:0;
text-align:center;
}
#s_1818a1cee489c4aa8b670df5e37214a0{
margin:2px auto;
overflow:hidden;
width:320px;
height:260px;
}
#v_1818a1cee489c4aa8b670df5e37214a0{
margin:2px auto;
border:none;
overflow:hidden;
width:900px;
height:900px;
}
--></style>
<div id='s_1818a1cee489c4aa8b670df5e37214a0'><iframe id="v_1818a1cee489c4aa8b670df5e37214a0"></iframe></div>
<span id=timebox style="font-size:15px;color:red">Please wait for timer to run out before you click Vote.
<br/><b>Time left: <span id=time style="font-size:18px;color:orangered">00:00</span></b></span>
<iframe id="r_1818a1cee489c4aa8b670df5e37214a0" style='width:1px;height:1px'></iframe>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
var _0x26a5 = 0;
var cd=15;
var _0x30f4=0;
var _0xBAc6=0;
document.oncontextmenu= function(){return false;}
window.onbeforeunload = function () {        
  return "If you want your Coins click CANCEL (don't close this page / don't navigate away from this page) ! Take your time and vote correctly, Thank You !";
};
function v_d7efae08376aed18b60304277f70df6a(){
if(!_0x30f4)
$.ajax({
  type: "POST",
  url: ["\x69\x6E\x64\x65\x78\x2E\x70\x68\x70\x3F\x70\x3D\x76\x6F\x74\x65\x26\x74\x3D\x61"],
  data: "o=1&tm=1332718009",
  success: function(msg){
    if(msg.charCodeAt(0)=='x'.charCodeAt(0)){
      var jq=window.opener.$;
      jq('#cc').html(msg.slice(1));
      jq('#vp').html(parseInt(jq('#vp').html())+1);
      window.opener.cd1=28800;
      window.onbeforeunload = null;
      window.close();
    }else if(msg.charCodeAt(0)=='y'.charCodeAt(0)){
      window.onbeforeunload = null;
      window.close();
    }else if(msg.charCodeAt(0)=='P'.charCodeAt(0)){
      alert(msg);
      window.onbeforeunload = null;
      window.close();
    }else{
      alert('Error: '+msg);
      window.onbeforeunload = null;
      window.close();
    }
  },
  error: function(msg){
    alert('Error: '+msg);
    window.onbeforeunload = null;
    window.close();
  }
});
else alert("No cheating please :D Take your time and vote correctly, Thank You !")
}
function _0xd7efae08376aed18b60304277f70df6a() {
 _0x26a5++;
 if (_0x26a5==2) setTimeout('v_d7efae08376aed18b60304277f70df6a()',200);
}
function _0x30d7efae08376aed18b60304277f70df6a() {
_0x30f4=1;
}
function ctv(sec){
  sec = parseInt(sec);
  hh = sec / 3600;
  hh = parseInt(hh);
  mmt = sec - (hh * 3600);
  mm = mmt / 60;
  mm = parseInt(mm);
  ss = mmt - (mm * 60);
  if (ss < 10) { ss = "0"+ss; }
  if (mm < 10) { mm = "0"+mm; }
  if (hh < 10) { hh = "0"+hh; }
  return (mm.toString()+':'+ss.toString());
}
function _0xBAd7efae08376aed18b60304277f70df6a(){
_0xBAc6=1;
}
function cdv(){
 $.cto=setTimeout('cdv()', 999);
 if (cd == 0){
   $("#timebox").html('<b>You can click Vote <span style="font-size:18px;color:orangered">NOW !</span></b>');
   if($.cto) clearTimeout($.cto);
 }else{
   cd=cd-1;
   $("#time").text(ctv(cd));
 }
};
$(document).ready(function(){
 if($.cto) clearTimeout($.cto);
 cdv();
 $('#s_1818a1cee489c4aa8b670df5e37214a0').scrollTop(110).scrollLeft(392);
 $('#v_1818a1cee489c4aa8b670df5e37214a0').attr('src',"http://www.xtremetop100.com/in.php?site=1132330134");
 var _0x742e=["\x6C\x6F\x61\x64","\x23"];$(_0x742e[1]+'v_1818a1cee489c4aa8b670df5e37214a0')[_0x742e[0]](function (){_0xd7efae08376aed18b60304277f70df6a();} );
 $('#s_1818a1cee489c4aa8b670df5e37214a0').bind('click',function(){_0xBAd7efae08376aed18b60304277f70df6a();});
 $('#v_1818a1cee489c4aa8b670df5e37214a0').bind('click',function(){_0xBAd7efae08376aed18b60304277f70df6a();});
 $('#s_1818a1cee489c4aa8b670df5e37214a0').click(function(){_0xBAd7efae08376aed18b60304277f70df6a();});
 $('#v_1818a1cee489c4aa8b670df5e37214a0').click(function(){_0xBAd7efae08376aed18b60304277f70df6a();});
 var _0xdf3f=["\x6C\x6F\x61\x64","\x23"];$(_0xdf3f[1]+'r_1818a1cee489c4aa8b670df5e37214a0')[_0xdf3f[0]](function (){_0x30d7efae08376aed18b60304277f70df6a();} );
});
</script>
- Si inlocuiesti in codul JavaScript: http://www.xtremetop100.com/in.php?site=1132330134 cu adresa ta de vot.

LCristian Mesaje: 12
Primesc mesajul asta cand vrea sa "functioneze".
http://i39.tinypic.com/3532yw2.jpg

MarPlo Mesaje: 4343
Din ce pricep, acel mesaj e codul HTML al paginii de votare. Dar nu cunosc de ce se intampla asa, nici nu am idee de ceea ce fac instructiunile din codul dat mai sus.
L-am testat intr-un document HTML nou si a mers, dar sa ma bag cu mintea in el ca sa stiu ce face si de ce, ma depaseste.

LCristian Mesaje: 12
Alta metoda sa inchid pagina cand incearca sa fie redirectionata n`ar mai fi?

Subiecte similare