Killersites Community: How Do I Get This Code To Work? - Killersites Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How Do I Get This Code To Work?

#1 User is offline   joecool 

  • PipPipPip
  • View blog
  • Group: Member
  • Posts: 71
  • Joined: 15-January 11

Posted 12 March 2012 - 02:46 AM

Hi,

I am trying to set up an exit popup script so that when someone clicks on exit/close a page pops up in the background giving them an option to stay on the page for a special gift of some kind.

Once you have the script installed just below the </body> tag then you are supposed to be able to but the following code on any outgoing link so that it doesn't prompt the pop-up. onSubmit="throughlink()"

However, I have tried this and as yet, I can't get it to work. Does anyone know of a code I can put into outgoing links so that they do not trigger the popup when clicked on?

Or of an alternative way to do what I want to do?

Here is the javascript for the popup.

<script type="text/javascript">
<!--
var allowPrompt = true;

done = false;
window.onbeforeunload = WarnUser;


function throughlink(){
throughlink = true;
}

function WarnUser()
{
if(allowPrompt && throughlink !=true && done !=true)
{
done = true;
// Place your upsell URL here
document.location = " ******* exit page url goes here******** ";


var message = "WAIT! WAIT! Don't leave empty handed... ";




return message;
}
else
{
// Reset the flag to its default value.
allowPrompt = true;
}
}

window.setTimeout("resetdone()", 1000);

function resetdone(){
done = false;
}

function NoPrompt()
{
allowPrompt = false;
}

// -->
</script>
What you looking at? Nothing to see here...
0

#2 User is offline   Ben 

  • View blog
  • Group: Administrators
  • Posts: 5,419
  • Joined: 19-December 08
  • LocationChico, CA

Posted 13 March 2012 - 11:22 PM

To be honest, this isn't something I have any experience with. My impression is that you can't really do what you have in mind -- I think the "window.onbeforeunload" gets called any time a window gets changed, and the only way you can skip this function is adding the "throughlink()" function to all links.
Benjamin Falk | Falken Creative : Twitter : KillerSites Screencast Blog
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
0

#3 User is offline   joecool 

  • PipPipPip
  • View blog
  • Group: Member
  • Posts: 71
  • Joined: 15-January 11

Posted 15 March 2012 - 02:24 AM

View PostBen, on 14 March 2012 - 04:22 AM, said:

To be honest, this isn't something I have any experience with. My impression is that you can't really do what you have in mind -- I think the "window.onbeforeunload" gets called any time a window gets changed, and the only way you can skip this function is adding the "throughlink()" function to all links.



Okay, Thanks
What you looking at? Nothing to see here...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users