I made a contact form. The form calls a php file. This successfully saves surname, name, email, message and a file to my webpage host.
At the bottom of upload1file2.php I put some html to say “Success! File uploaded, details saved”
I also want to have 2 html buttons. 1 links back to the form page. That works OK.
I would like another button to close the tab in the browser if the user is finished.
I have this html, but it does not work. Apparently, the problem is, if the script did not open the page,
window.close() wil not shut it. I will try to tweak it to shut the page.
<ul style="display:inline-table; width:950px;">
<li> <a href="http://www.mywebpage.com/form1.html">Go back<p>返回</p></a> </li>
<li> <a href="javascript:window.open('','_self').close();">close</a> </li>
<li> <a href="#" id="close-window">Close this window tab</a> </li>
</ul>
</div>
<script type="text/javascript">
document.getElementById("close-window").addEventListener("click", function(){
window.open('','_parent',''); # this is supposed to fool the browser that this script opened the webpage
window.close();
});
</script>
My questions therefore is: As upload1file2.php opens this success-page: Can I use php to make it close?