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.
Asked
Active
Viewed 8,505 times
2
-
I think you are looking for something like this: http://stackoverflow.com/questions/4059179/refresh-child-window-from-parent-window – alu Feb 11 '13 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 Feb 11 '13 at 21:57
-
@Peter, reload and check my answer. – Lawrence Cherone Feb 11 '13 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 May 23 '17 at 21:33
1 Answers
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>

Lawrence Cherone
- 46,049
- 7
- 62
- 106
-
OK great, reload worked, for my situation I used: `theform.submit();` `location.reload();` as I needed the form data to be POSTed. Thanks. – Peter Feb 11 '13 at 22:42
-
@Lawrence You legend :D iv been scratching my head for quite a while over this problem. Thanks – AndrewBramwell May 23 '17 at 21:32