javascript - Open New Window on Submit Button with "parent.location" - Stack Overflow

I'm having a hard time getting a submit button to open a link in a new window.The button code:<

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 badge
Add a ment  | 

3 Answers 3

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')">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745307494a4621800.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信