Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <!--
- Author: Affbuddy
- Site: https://affbuddy.com/
- Youtube: https://www.youtube.com/watch?v=cSebDfjrM20
- -->
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="robots" content="noindex, nofollow">
- <title>Javascript Exit Pop Example</title>
- <link rel="shortcut icon" href="https://s3.amazonaws.com/affbuddy/favicon.png">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
- <style>
- @import url(https://fonts.googleapis.com/css?family=Bangers);
- body {
- text-align: center;
- }
- .header {
- margin: auto;
- margin-bottom: 30px;
- padding-top: 10px;
- height: 120px;
- background-color: #2a3a47;
- }
- .logo {
- margin: auto;
- background-image: url(https://s3.amazonaws.com/affbuddy/logo.png);
- background-repeat: no-repeat;
- width: 315px;
- height: 100px;
- }
- .title {
- font-family: 'Bangers', cursive;
- margin-bottom: 60px;
- }
- .panel {
- margin: auto;
- min-height: 300px;
- max-width: 400px;
- border: 6px dashed #ff0000;
- cursor: pointer;
- }
- .panel-body {
- font-size: 20px;
- }
- </style>
- <!--[if IE]>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
- <![endif]-->
- </head>
- <body>
- <div class="header">
- <div class="container">
- <div class="logo"></div>
- </div>
- </div>
- <div class="container">
- <h1 class="title">Javascript Exit Pop Example</h1>
- <div class="panel panel-default" data-href="http://example.com">
- <div class="panel-body">
- <h1>Mega Store Coupon</h1>
- <h2>Save 50% to 90%</h2>
- <br />
- <h2><a href="#">CLICK HERE</a></h2>
- </div>
- </div>
- </div><!-- container -->
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- <script>
- var counter = 2; // number of exit pops before we let them go
- function pop() {
- if (counter > 0) {
- counter--;
- return "Are you sure you want to leave?";
- }
- }
- function nopop() {
- // nothing to return
- }
- $(function() {
- window.onbeforeunload = pop;
- $(".panel").click(function() {
- window.onbeforeunload = nopop;
- });
- });
- </script>
- <script>
- $(function() {
- $(".panel").click(function() {
- window.open($(this).data("href"));
- //setTimeout(function(){
- // window.location.href = "http://bing.com";
- //},500);
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement