Reputation: 1428
I am writing an HTML application that passes a bunch of form elements along to a PHP script, that will run a Python script using those values.
The form element in my page looks like:
<form id="main-input" action="shell.php" method="post" target="_blank">
This opens a new tab, with the PHP script inside. It is an otherwise blank page, with no text on it (since there is asynchronous data display).
Since I do not want the user to mistakenly close this tab (since it would stop script execution) and also since it could cause other confusion, is there a way to make the new browser tab invisible, but still active, using HTML?
More to the point, is there a way to have an invisible broswer tab?
Upvotes: 0
Views: 410
Reputation: 3726
Ehm, just have an invisible iframe and post to it with form target. It is not really an invisible browser tab, yet the most close you get to it - maybe an inline browser tab :)
<form id="main-input" action="shell.php" method="post" target="anyname"></form>
<iframe name = 'anyname' src = 'blubb.php' style = 'display: none'></iframe>
No need for AJAX so far and the nearest to your idea as possible.
Upvotes: 1
Reputation: 131
Answer: No, there's no way that I know of to make an invisible browser tab (for security and annoyance reasons).
Suggestion: Instead of posting to another tab, you should submit a Post using ajax instead. Override the normal submit action of the form...
... and then proceed to gather the form values and compile a Post request. Here's a jQuery reference to using Ajax... http://www.w3schools.com/jquery/jquery_ajax_get_post.asp
Here's a more general JavaScript reference from W3 Schools: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
Upvotes: -1