最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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')">
发布评论

评论列表(0)

  1. 暂无评论