admin管理员组

文章数量:1304149

In my LAMP stack application I create invoices in pdf format. The first screen allows selections of purchase items to be included in the invoice. My pdf opens in a new tab using the $_POSTed form data which works fine, but I would also like to simultaneously reload the first page as I also update the status of purchases selected for the pdf invoice and I want the selection screen to reflect this. Any ideas anyone? NB Native Javascript or PHP solutions only please.

In my LAMP stack application I create invoices in pdf format. The first screen allows selections of purchase items to be included in the invoice. My pdf opens in a new tab using the $_POSTed form data which works fine, but I would also like to simultaneously reload the first page as I also update the status of purchases selected for the pdf invoice and I want the selection screen to reflect this. Any ideas anyone? NB Native Javascript or PHP solutions only please.

Share Improve this question edited Oct 25, 2018 at 20:38 Rytis 1,4451 gold badge19 silver badges39 bronze badges asked Feb 11, 2013 at 21:46 PeterPeter 2114 silver badges12 bronze badges 4
  • I think you are looking for something like this: stackoverflow./questions/4059179/… – alu Commented Feb 11, 2013 at 21:51
  • Close, but no cigar - that Q is to do with refreshing a child window from parent. I want to open a child window and refresh the parent at the same time. – Peter Commented Feb 11, 2013 at 21:57
  • @Peter, reload and check my answer. – Lawrence Cherone Commented Feb 11, 2013 at 21:59
  • I just had exactly the same problem as you, im building exactly the same thing as you :) it would be interesting to see what you're doing :D – AndrewBramwell Commented May 23, 2017 at 21:33
Add a ment  | 

1 Answer 1

Reset to default 8

Perhaps something like this:

<a onclick="open_in_new_tab_and_reload('./path_to_pdf.pdf')" href="#">PDF</a>

<script>
function open_in_new_tab_and_reload(url)
{
  //Open in new tab
  window.open(url, '_blank');
  //focus to thet window
  window.focus();
  //reload current page
  location.reload();
}
</script>

本文标签: javascriptLaunch a new tab and reload original pageStack Overflow