I'm having a hard time getting a submit button to open a link in a new window.
The button code:
<input type="button" name="buy" value="Buy" onClick="parent.location='myurl'" />
I tried to add a target="_blank" to the form, but that didn't help.
Is it possible to open a new window using this "parent.location" method or any equivalent.
I'm afraid my shopping cart script won't work any longer if I change the code too much.
Best regards,
Erik Chan
I'm having a hard time getting a submit button to open a link in a new window.
The button code:
<input type="button" name="buy" value="Buy" onClick="parent.location='myurl'" />
I tried to add a target="_blank" to the form, but that didn't help.
Is it possible to open a new window using this "parent.location" method or any equivalent.
I'm afraid my shopping cart script won't work any longer if I change the code too much.
Best regards,
Erik Chan
Share Improve this question asked Feb 11, 2011 at 9:53 Erik ChanErik Chan 11 gold badge1 silver badge1 bronze badge3 Answers
Reset to default 1<form action="whatever" method="post" target="foo" onSubmit="window.open('', 'foo', 'width=1040,height=900,status=yes,resizable=yes,scrollbars=yes')">
This should work for your needs. I have used this time and time again
<input type="button" name="buy" value="Buy" onClick='window.open("http://www.abcd./")' />
see it for open function param http://www.w3schools./jsref/met_win_open.asp
Try window.open() method.
<input type="button" name="buy" value="Buy" onclick="window.open('myurl')">