POPUP Just once

I use this script to open a popup in a form (1st page), it works good BUT after submitting the form it appears again in confirmation page. I want it to appear just once : What parameter should i add to my script ?

Thank you

EDIT :

This code Exists in a page that contains a form (myform.php) when submitting this form an action [myform.php?action=confirmation] is taken, so in that confirmation page – that is a part of the process of (myfom.php) – The popup (timer.html) appears again. i use ./lib/jquery-1.4.4.min.js..

    var $fb_pop = jQuery.noConflict();

    $fb_pop(document).ready(function(){
        setTimeout( function(){ $fb_pop.colorbox({href:"./timer/timer.html", iframe:true, innerWidth:"150px", height:"40%", maxHeight:"200px", fixed:true}) }, 5000 );
        $fb_pop(".fb_iframe").colorbox({iframe:true, innerWidth:"150px", height:"40%", maxHeight:"150px", fixed:true }); 
    });

Answer

The pop up appears again as the page is reloaded by the form’s submit action, thereby executing the javascript code in it again. Execute the javascript only when there is no ‘action’ parameter in the url.

<?php
if (!isset($_GET['action'])) { ?>

     var $fb_pop = jQuery.noConflict();

     $fb_pop(document).ready(function(){
        setTimeout( function(){ 
           $fb_pop.colorbox({
             href:"./timer/timer.html", 
             iframe:true, 
             innerWidth:"150px", 
             height:"40%", 
             maxHeight:"200px", 
             fixed:true}) 
         }, 5000 );
    $fb_pop(".fb_iframe").colorbox({
       iframe:true, 
       innerWidth:"150px", 
       height:"40%", 
       maxHeight:"150px", fixed:true }); 
    });    

<?php 
} ?>

Edit 1 Since you are including the html page inside myform.php through the include() function, make a simple check with javascript to see if the URL contains ‘action’ text.

  if (window.location.href.indexOf("action") === -1) {
    // include your script here
  }

Leave a Reply

Your email address will not be published. Required fields are marked *