how to center pop up window on scereen?

Discussion in 'Programming' started by Mohammed Sabah, Apr 7, 2013.

  1. #1
    Good day to every one
    im trying to centre the pop up window and not sure how to make it.
    below is the script

    <script language="javascript">
    function target_popup(form) {
        window.open('', 'formpopup', 'width=900,height=400, resizeable,scrollbars,');
        form.target = 'formpopup';
    }
    </script>
    HTML:

     <form id="theform" name="order" method="post" action="confirm.php" onsubmit="target_popup(this)" enctype="multipart/form-data" style="position:absolute; left:0px; top:0px">
    Code (markup):


    Thank you :)
     
    Mohammed Sabah, Apr 7, 2013 IP
  2. Mohammed Sabah

    Mohammed Sabah Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    is my question celar? or difficult :(

    Please if any one can help.
    Thank you
     
    Mohammed Sabah, Apr 8, 2013 IP
  3. quocduan

    quocduan Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    why don't u use modal box?
     
    quocduan, Apr 8, 2013 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    You will need the width & height of the window:

    
    function popupwindow(url, title, w, h) {
      var left = (screen.width/2)-(w/2);
      var top = (screen.height/2)-(h/2);
      return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
    }
    
    Code (markup):
    Source
     
    ThePHPMaster, Apr 13, 2013 IP