www.webdeveloper.com
Results 1 to 2 of 2

Thread: [IE7-8] Problem to submit a form in a popup

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    2

    [IE7-8] Problem to submit a form in a popup

    Hello all,

    It's my first post here, so I wish me the welcome :-)

    I try to submit a form in a new popup, it is working well in FF and Chrome, but not in IE7-8.
    I just have a form like this :
    HTML Code:
    <div id="btn" class="btn" style="width: 70px;">
    			<a id="mya">
    				// some div here to build a button
    			</a>
    		</div>
    		<form id="myForm"  method="POST"
    			action="/mypage"
    			accept-charset="ISO-8859-1" target='popup'
    			onsubmit="window.open('', 'popup', 'width=800,height=670,top=0,left=100,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,status=yes')">
    			<input type="hidden" name="login" id="login" value="login">
    			<input type="hidden" name="password" id="password" value="pwd">
    		</form>
    And a little bit of jQuery JS:
    Code:
    jQuery('#mya').click(
        $('#myForm').submit();
    );
    It seems very simple to me. FF and Chrome handle that correctly, but IE opens the popup and submit the form in the parent window.

    Testing some workarounds, I made a mistake and wrote this HTML code (I wrote "options" in the window.open, which is of course not valid) :
    HTML Code:
    <div id="ipanema-btn" class="btn" style="width: 70px;">
    			<a id="ipanema-a">
    				// some div here to build a button
    			</a>
    		</div>
    		<form id="myForm"  method="POST"
    			action="/mypage"
    			accept-charset="ISO-8859-1" target='popup'
    			onsubmit="window.open('', 'popup', options)">
    			<input type="hidden" name="login" id="login" value="login">
    			<input type="hidden" name="password" id="password" value="pwd">
    		</form>
    With this incorrect code, it work pretty great in IE too ! A popup is opened and the form is submitted in it, but of course the properties of the popup are not good (in all browsers).

    Do someone have an idea to have this working with popup options in all browsers ?

    Thank you very much !

  2. #2
    Join Date
    Dec 2012
    Posts
    2
    I have done some more tests. I found a solution for IE which is to remove the jquery click handler :
    Code:
    <div id="btn" class="btn" style="width: 70px;">
    			<a id="mya" onclick="document.getElementById('ipanemaForm').submit();">
    				// some div here to build a button
    			</a>
    		</div>
    		<form id="myForm"  method="POST"
    			action="/mypage"
    			accept-charset="ISO-8859-1" target='popup'
    			onsubmit="window.open('', 'popup', 'width=800,height=670,top=0,left=100,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,status=yes')">
    			<input type="hidden" name="login" id="login" value="login">
    			<input type="hidden" name="password" id="password" value="pwd">
    		</form>
    But this is not working in FF ! It opens a new tab when clicking the button.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles