Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- window.onload = function() {
- /* set your parameters(
- number to countdown from,
- pause between counts in milliseconds,
- function to execute when finished
- )
- */
- // startCountDown(15, 1000, myFunction);
- }
- function startCountDown(i, p, f) {
- // store parameters
- var pause = p;
- var fn = f;
- // make reference to div
- var countDownObj = document.getElementById("countDown");
- if (countDownObj == null) {
- // error
- alert("div not found, check your id");
- // bail
- return;
- }
- countDownObj.count = function(i) {
- // write out count
- countDownObj.innerHTML = i;
- if (i == 0) {
- // execute function
- fn();
- // stop
- return;
- }
- setTimeout(function() {
- // repeat
- countDownObj.count(i - 1);
- },
- pause
- );
- }
- // set it going
- countDownObj.count(i);
- }
- function myFunction() {
- //alert("hi alex");
- ShowOptions(1);
- }
- function popUpClosed() {
- window.location.reload();
- }
- var ajaxObj=new getAjaxObject();
- function getAjaxObject()
- {
- var XMLHttpRequestObject = false;
- if (window.XMLHttpRequest)
- {
- XMLHttpRequestObject = new XMLHttpRequest();
- }
- else if (window.ActiveXObject)
- {
- XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
- }
- if (!XMLHttpRequestObject)
- {
- alert("Your browser does not support Ajax."); return false;
- }
- return XMLHttpRequestObject;
- }
- //var loads=false;
- function createpopup(website)
- {
- //alert('popup');
- document.getElementById('webframe').src=website;
- //popupWindow = window.open(website,'mypopup','width=400,height=400');
- //popupWindow.onclose=function(){alert('unload');}
- //popupWindow.onclose = function(){ alert('unload');}
- //popupWindow.onbeforeunload=function(){ alert('unload');}
- }
- function closeMe(evt) {
- alert('ff');
- /*if (typeof evt == 'undefined') {
- evt = window.event; }
- if (evt && evt.clientX >= (window.event.screenX - 150) &&
- evt.clientY >= -150 && evt.clientY <= 0) {
- return "Do you want to log out of your current session?";
- }*/
- }
- var callback = function(){
- //alert("foo");
- window.location.reload();
- };
- function pollForWindowClosure(){
- if(popupWindow.closed){
- callback();
- return;
- }
- setTimeout(pollForWindowClosure, 10);
- }
- function changepopupurl(website)
- {
- //window.popupWindow.location=website;
- document.getElementById('webframe').src=website;
- //popupWindow.onbeforeunload = function(){ alert('unload');}
- ///popupWindow = window.open(website,'mypopup','width=400,height=400');
- }
- function ShowOptions(id)// kahi se call karo is ko
- {
- //alert(id);
- var limm= document.getElementById('sit').value;
- //popupWindow = window.open('childpage.php?lim='+limm,'name','width=400,height=400');
- //if(loads)
- // {
- //window.opener.location.href='http://www.google.com';
- //alert('window');
- //}
- var xmlHTTPObject=new getAjaxObject();
- var lim= document.getElementById('site').value;
- var limm= document.getElementById('sit').value;
- var website= document.getElementById('siturl').value;
- // var website="<?php //echo SITE_URL;?>/web.php?wid="+limm;
- //alert(website);
- if(id==0)
- {
- //Opt();
- //loads=true;
- createpopup(website);
- //pollForWindowClosure();
- }
- else
- {
- changepopupurl(website);
- }
- var url='get.php?lim='+lim;
- var parameters='123';
- //alert(url);
- var timers;
- if(xmlHTTPObject)
- {
- if (xmlHTTPObject.readyState == 4 || xmlHTTPObject.readyState == 0)
- {//alert(xmlHTTPObject.readyState);
- xmlHTTPObject.open("GET", url, true);
- // alert('open');
- xmlHTTPObject.onreadystatechange =function()
- {
- if (xmlHTTPObject.readyState == 4)
- {
- if (xmlHTTPObject.status == 200)
- {
- try
- {
- var XMLResponse = xmlHTTPObject.responseText;
- timers =XMLResponse;
- document.getElementById('sites').innerHTML=XMLResponse;
- var countDowntime=document.getElementById('countDowntime').value;
- //alert(XMLResponse);
- Opt(countDowntime);
- startCountDown(countDowntime, 1000, myFunction);
- }
- catch(e){}
- }
- }
- };
- xmlHTTPObject.send(null);
- }
- }
- //setTimeout ( "ShowOptions(1)", 20000);
- return false;
- }
- function Opt(countDowntime)// kahi se call karo is ko
- {
- var xmlHTTPObject=new getAjaxObject();
- var url='update.php?countDowntime='+countDowntime;
- var parameters='123';
- var timers;
- if(xmlHTTPObject)
- {
- if (xmlHTTPObject.readyState == 4 || xmlHTTPObject.readyState == 0)
- {
- xmlHTTPObject.open("GET", url, true);
- xmlHTTPObject.onreadystatechange = function ()
- {
- if (xmlHTTPObject.readyState == 4)
- {
- if (xmlHTTPObject.status == 200)
- {
- try
- {
- var XMLResponse = xmlHTTPObject.responseText;
- //alert(XMLResponse);
- }
- catch(e){}
- }
- }
- };
- xmlHTTPObject.send(null);
- }
- }
- //setTimeout ( "ShowOptions()", 200000);
- return false;
- }
- window.onload = function() {
- /* set your parameters(
- number to countdown from,
- pause between counts in milliseconds,
- function to execute when finished
- )
- */
- // startCountDown(15, 1000, myFunction);
- ShowOptions('0');
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement