I have a popup with a form on it. when the form is submitted i want it to load the next page in a new window (not in the popup window). Does anyone know how the submission code can be chainged to do this?

<!--webbot bot="SaveResults" S-Email-Format="TEXT/PRE" S-Email-Address="webmaster@kings-head-inn.com" B-Email-Label-Fields="TRUE" B-Email-Subject-From-Field="FALSE" S-Email-Subject="MSN 8" S-Date-Format="%Y-%m-%d" S-Time-Format="%H:%M:%S" S-Builtin-Fields="REMOTE_NAME REMOTE_USER HTTP_USER_AGENT Date Time" S-Form-Fields="T1 [B]" U-Confirmation-Url="" -->[/B]

Cheers,
NuGG

Dani AI

Generated

Short summary and a robust pattern to follow.

As pointed out, target="_blank" is the simplest option, and as noted it doesn't always give you the control you want when the form lives in a popup. 's JavaScript approach is the right direction. The pattern below opens a new browsing context explicitly, assigns the form to that window, and falls back cleanly if a popup is blocked.

<form id="myForm" action="/submit" method="post" target="_blank">
  <!-- fields -->
</form>

<script>
(function () {
  var form = document.getElementById('myForm');
  form.addEventListener('submit', function () {
    // open an empty named window immediately (user-initiated)
    var win = window.open('', 'submissionResultWindow');
    if (win) {
      try { win.opener = null; } catch (e) {}
      form.target = 'submissionResultWindow'; // uses the named window
    } else {
      form.target = '_blank'; // fallback if popup was blocked
    }
    // allow normal submit to continue
  }, false);
})();
</script>

Notes and cautions:

  • A named target (like submissionResultWindow) will reuse the same tab/window on subsequent submits. Use _blank if you want a fresh tab every time.
  • Call window.open synchronously in the submit handler (user click) to avoid popup blockers. If you open asynchronously, many browsers will block it.
  • For security (reverse-tabnabbing) try to null the opener (win.opener = null) where supported, and be mindful of cross-origin behavior.
  • If your server-side handler redirects to a confirmation URL, that redirect will appear in whichever target the form used.

This gives deterministic behavior (new window outside the popup) while preserving a no-JavaScript fallback.

Recommended Answers

All 3 Replies

typically if you want a link to pop in a new window you add "target=blank" in your code.

In this case I don't think that will work, and there doesn't appear to be a webbot command for it.

Ok I think i've sussed it. I've written a short javascript which does the job perfectly.

Thanks for your help,

NuGG

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.