Closing popup window after 3 seconds

I need to close the popup windows in the following after 3 seconds. How do I do it.

<map id="ImgMap0" name="ImgMap0">
                  <area alt="" coords="127, 22, 20" alt="" title="click here" href="includes/popup1.htm" onclick="javascript:void window.open

('includes/popup1.htm','1366002941508','width=500,height=200,left=375,top=330');return false;" shape="circle" />
</map></p>

Answers:

Answer

Use a setTimeout, for example:

var win = window.open("http://www.google.com", '1366002941508','width=500,height=200,left=375,top=330');

setTimeout(function () { win.close();}, 3000);

Sample fiddle: http://jsfiddle.net/N5rve/

Answer
<script type="text/javascript">
 function closeWindow() {
    setTimeout(function() {
    window.close();
    }, 3000);
    }

    window.onload = closeWindow();
    </script>

That should do it.

Answer

This is an example of JavaScript automatic popup closing after 3 seconds with countdown,

<p style="text-align:center">This window will close automatically within <span id="counter">3</span> second(s).</p>
<script type="text/javascript">



 function countdown() {

    var i = document.getElementById('counter');

    i.innerHTML = parseInt(i.innerHTML)-1;

 if (parseInt(i.innerHTML)<=0) {

  window.close();

 }

}

setInterval(function(){ countdown(); },1000);

</script>

I have found it here. Hope this will be helpful for you.

Answer

Try

<area alt="" coords="127, 22, 20" alt="" title="click here" href="includes/popup1.htm" onclick="openWindow()" shape="circle" />

function openWindow(){
    var win = window.open('includes/popup1.htm', '1366002941508',  'width=500,height=200,left=375,top=330');
    setTimeout(function(){
        win.close()
    }, 3000);
    return false;
}
Answer
<area alt="" coords="127, 22, 20" alt="" title="click here" href="includes/popup1.htm" onclick="openWindow()" shape="circle" />

function openWindow(){
    var win = window.open('includes/popup1.htm', '1366002941508',  'width=500,height=200,left=375,top=330');
    setTimeout(function(){
        win.close()
    }, 3000);
    return false;
}
Answer

use this tutorials to get what you want

http://www.tizag.com/javascriptT/javascriptredirect.php

<html>
  <head>
   <script type="text/javascript">
     function close_popup(){
        //code here...
     }
  </script>
 </head>
 <body onLoad="setTimeout('close_popup()', 3000)"> // 3000 milisec = 3sec

 </body>
</html>
Answer

Creating a global variable and reuse it in our code.

var info = function (text, onClose, headerText) {
              if (!headerText)
                headerText = "Info";
    
            alert(text, null, onClose, headerText, true);
    }
    
    // Call this in own code where ever you need
    
    info("Message that going to close automatic.");
    hidePopUpMessage();
    
    // callback function to showing 3 sec.
    function hidePopUpMessage() {
            setTimeout(function () {
                $("#pp-alert-close").click();
                //$("#popup-close").click();
            }, 3000);
        }

Answer
<script type="text/javascript">
    function popup() {
        var myPopup = window.open('includes/popup1.htm','1366002941508','width=500,height=200,left=375,top=330');
        var t=setTimeout(myPopup.close(),3000);
        return false;
    }
</script>
<map id="ImgMap0" name="ImgMap0">
    <area alt="" coords="127, 22, 20" alt="" title="click here" href="includes/popup1.htm" onclick="popup();" shape="circle" />
</map>

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.