JavaScript 无需点击按钮的表单功能

JavaScript function of form without click the button

这是我完成的代码,用于执行通过 javascript 进入 PayPal 支付网关而无需单击“立即购买”按钮的表单功能。只是我的问题在这里,这将打开一个新的 window 来做到这一点,我希望这个功能在同一个 window 上完成。请指导我如何解决它?任何帮助将不胜感激。

window.onload = function() {
   
  // u should put a name for your form
  document.forms['my_form'].submit();
}
<form target="PayPal" id="my_form" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:0;padding:0;">
  <input type="hidden" name="business" value="test@yahoo.com">
  <input type="hidden" name="cmd" value="_xclick">
  <input type="hidden" name="item_name" value="Membership">
  <input type="hidden" name="item_number" value="1 Month">
  <input type="hidden" name="amount" value="23">
  <input type="hidden" name="currency_code" value="USD">
  <input type="hidden" name="shipping" value="">
  <input type="hidden" name="shipping2" value="">
  <input type="hidden" name="handling" value="">
  <input type="hidden" name="return" value="https://test.com/Successful_Payment.php">
  <input type="hidden" name="cancel_return" value="">
  <input type="hidden" name="undefined_quantity" value="0">
  <input type="hidden" name="receiver_email" value="test@yahoo.com">
  <input type="hidden" name="no_shipping" value="1">
  <input type="hidden" name="no_note" value="0">
</form>
```

从表单中删除属性 target="Paypal"