I am trying to post a form in a new window using JavaScript.
let form = document.createElement('form');
form.target = 'example.com';
form.method = 'POST';
form.submit();
window.open('', form.target);
The above code submits the form in a new window. This solution works fine until someone navigates to a different URL in the new tab. Let's say google.com. On Subsequent click, this does not work as it stays on google.com instead of posting to example.com.
I need to post a www-url-form-encoded content-type in a new window and keep the reference of the tab so subsequent clicks opens the same tab if it is already opened.