Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Exit PopUp


ardit

Recommended Posts

Hey there I want to have an exit popup thanking the visitors for their visit and giving them the option to leave a feedback. I got a script of a javascipt site here is the code

 

<script>



/*

Fair well window launcher script

By JavaScript Kit (http://javascriptkit.com)

Over 200+ free scripts here!

*/



function openpopup(){

//configure "seeyou.htm and the window dimensions as desired

window.open("seeyou.htm","","width=300,height=338")

}



function get_cookie(Name) {

 var search = Name + "="

 var returnvalue = "";

 if (document.cookie.length > 0) {

   offset = document.cookie.indexOf(search)

   if (offset != -1) { // if cookie exists

     offset += search.length

     // set index of beginning of value

     end = document.cookie.indexOf(";", offset);

     // set index of end of cookie value

     if (end == -1)

        end = document.cookie.length;

     returnvalue=unescape(document.cookie.substring(offset, end))

     }

  }

 return returnvalue;

}



function loadpopup(){

if (get_cookie('popped')==''){

openpopup()

document.cookie="popped=yes"

}

}



</script>



<body onunload="loadpopup()">

 

How would I implement this in php because it is for a plain html page and also I really don't know where to put it. If you implement it in the default page then when they go to some other page it would appear. How do I make this to work or does anyone of you have a script that would do the same thing but when the visitor leaves the entire site...

 

Thanks in advance

Ardi

Link to comment
Share on other sites

Hello,

 

I just tested your code on my header file. If you edit includes/header.php and at the very top, just drop the code in. Should then work for you :)

 

HTH

Kindest Regards,

 

Carl Pickering

 

If there is light at the end of the tunnel, switch it off. I have to save on my electricity bill

Link to comment
Share on other sites

Ok I tried what carlp said and it works but the popup is desplayed immidiatly after you leave the default page to go anywhere else in the site. Is there anyway to make it so that it pops up once the visitor leaves the website, the domain?

Link to comment
Share on other sites

wouldn't then be displayed only if they successfully complete an order?! I want it to be displayed when they leave the site – if they buy or not. The only thing that I have thought up to now is have an invisible frame somehow and have the code in there, but that would create problems with search engines and frames are never advisable.

Link to comment
Share on other sites

I don't know how to do this, but I think that it is possible to test to what page it is going when you run the function. I.e. I think that there is a variable or something that you can check. Then you just add a test to see if it is going somewhere else in your site. If it is, do nothing. If not, make the popup (which btw would annoy me if I were using your site, just fyi).

 

Note: you would want to put this into the footer or something that gets included on every page.

 

Unfortunately, my javascript skills are very low, so I'm not sure how to do this (i.e. what variable to use and how to do string matching).

 

Hope this helps,

Matt

I love deadlines. I like the whooshing sound they make as they fly by. ---Douglas Adams

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...