Hi there guys,
I'm new to this forum !!! Im a newby.

I was having a problem with a new site I am working on.

I need to be able to open a new browser window from a pop-up.

I have a main page, that has a pop-up window. Inside that pop-up I have a Paypal Form with button, that when pressed I would like to open a Blank NEW Window.

At the moment it is opening the window inside the pop-up....

Is there some Javascript or something I can force a new window, like Break_out_of_frame ??

Hopeing you can help.

Warren

Dani AI

Generated

Good catch by @vishesh — you want the form to POST to a new window, but your current setup runs a JS function instead of performing a normal HTTP POST. That is why PayPal never sees the form fields and why the payment page loads inside the pop‑up (the form submits to the current window by default). Two simple, reliable fixes are below.

The easiest (no JS) — let the browser open a new tab/window for the POST:

<form action="PAYPAL_URL" method="post" target="_blank">
  <!-- hidden PayPal fields here -->
  <button type="submit">Pay with PayPal</button>
</form>

If you need to control window size or guarantee a separate window (instead of a tab), open an empty named window first and then submit the form to that window:

<script>
function submitToNewWindow(form) {
  var win = window.open('', 'paypalWin' + Date.now(), 'width=800,height=600');
  form.target = win.name;
  form.submit();
  win.focus();
  return false; // prevent any default action duplication
}
</script>

<form action="PAYPAL_URL" method="post" onsubmit="return submitToNewWindow(this);">
  <!-- hidden PayPal fields here -->
  <button type="submit">Pay with PayPal</button>
</form>

Troubleshooting notes: do not use action="javascript:..." — that prevents the browser doing a standard POST. Keep the window.open call inside the submit/click event so popup blockers usually allow it. Named windows are reused if you use the same name; append a timestamp if you want a fresh window every time. Make sure method="post" and your hidden PayPal inputs are present so PayPal receives the data.

Recommended Answers

All 2 Replies

Member Avatar for Member #114696

Hi vishesh,
Thanks for your reply.

I was wondering how you would fit that into the action of a form? I tried it (successfully opening the new window) but it's not passing any info...to my Paypal server.

I have this:

<SCRIPT language="JavaScript1.2">
function openwindow()
{
    window.open("","mywindow");
}
</SCRIPT>

and a form with this:

<form action="javascript: openwindow()" method="post">
        <input type="hidden" name="cmd" value="_xclick">
        <input type="hidden" name="business" value="myemail@mybusiness.com">
        <input type="hidden" name="quantity" value="1">
        <input type="hidden" name="item_name" value="My Business">
        <input type="hidden" name="item_number" value="Busniess info">
        <input type="hidden" name="amount" value="25">
        <input type="hidden" name="no_shipping" value="0">
        <input type="hidden" name="no_note" value="1">
        <input type="hidden" name="currency_code" value="AUD">
        <input type="hidden" name="lc" value="AU">
        <input type="hidden" name="bn" value="PP-BuyNowBF">
        <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
        <img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">
      </form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.