SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question how to center pop up window on cereen?

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

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

    HTML Code:
     <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">
    Thank you

  2. #2
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is my question celar? or difficult

    Please if any one can help.
    Thank you

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Mohammed Sabah View Post
    Good day to every one
    im trying to centre the pop up window and not sure how to make it.
    The following seems to work:

    Code javascript:
    popupCenter('', 'formPopup', 900, 400, {
        resizable: 'yes',
        scrollbar: 'yes'
    });

    The popupCenter function just uses half of the existing width and height of the window:

    Code javascript:
    function popupCenter(pageURL, title, width, height, options) {
        options = options || {};
        options.left = (screen.width / 2) - (width / 2);
        options.top = (screen.height / 2) - (height / 2);
     
        return popup(pageURL, title, width, height, options);
    }

    And the popup function can be as complex or as simple as you like, but something like this should mean that it can be used for multiple types of situations:

    Code javascript:
    function popup(pageURL, title, width, height, options) {
        return window.open(pageURL, title,
            'width=' + (width || options.width || '') + ',' +
            'height=' + (height || options.height || '') + ',' +
            'left=' + (options.left || '') + ',' +
            'top=' + (options.top || '') + ',' +
            'toolbar=' + (options.toolbar || 'no') + ',' +
            'location=' + (options.location || 'no') + ',' +
            'directories=' + (options.directories || 'no') + ',' +
            'status=' + (options.status || 'no') + ',' +
            'menubar=' + (options.menubar || 'no') + ',' +
            'scrollbars=' + (options.scrollbars || 'no') + ',' +
            'resizable=' + (options.resizable || 'no') + ',' +
            'copyhistory=' + (options.copyhistory || 'no') + ','
        );
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you paul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •