Created
September 5, 2017 00:11
-
-
Save h4kun4matata/e8c3fa7b8e9370748737fcd7f6b2ee1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| var popup = { | |
| open : function() | |
| { | |
| this.popupWindow = window.open('http://www.facebook.com'); | |
| return setTimeout(function() { | |
| popup.close(); | |
| }, 3000); | |
| }, | |
| close : function() | |
| { | |
| this.popupWindow.close(); | |
| this.timeout = this.loop(); | |
| }, | |
| loop : function() | |
| { | |
| var self = this; | |
| // On first run open popup immediately, or wait 10 seconds and restart | |
| // the loop | |
| if (self.active === true) | |
| { | |
| return setTimeout(function() { | |
| self.timeout = self.open(); | |
| }, 5000); | |
| } | |
| else | |
| { | |
| self.active = true; | |
| self.timeout = self.open(); | |
| } | |
| }, | |
| clearLoop : function() | |
| { | |
| clearTimeout(this.timeout); | |
| this.active = false; | |
| } | |
| }; | |
| popup.loop(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment