SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    submit form to new blank browser page/window at specific size

    I have a form that when the user submits the form it opens to a new browser window. Is there any way to specify the size of the window so it's like 95% of the screen and centered when it opens?

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes.

    Open the window with
    Code:
    var submitWin = window.open('','submitWin', 'width='+x+',height='+y+',status=yes,scrollbars=yes,resizable=yes');
    and then set your form's target to submitWin.

    http://www.quirksmode.org/viewport/compatibility.html
    http://www.quirksmode.org/js/winprop.html
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure exactly sure where I would put the "var" statement. Would this be outside the form tags? Does it have to be between a <script> tags?

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    New Jersey
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you would put that line in your code where you want the window to open. The
    Code:
    window.open('','submitWin', 'width='+x+',height='+y+',status=yes,scrollbars=yes,resizable=yes');
    code is what actually opens the window.

    ~Mr_Bonez

  5. #5
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript"><!--
    function makeTarget(f,x,y) {
    var submitWin = window.open('','submitWin', 'width='+x+',height='+y+',status=yes,scrollbars=yes,resizable=yes');
    f.target = 'submitWin';
    }
    // -->
    </script>
    Code:
    <form ... onsubmit="makeTarget(this,400,300);">
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •