Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh a pop-up window using javascript

I am using

window.open("http://something...")

to open a pop-up window which shows a PDF file with some report on it when certain ajax success gets hit. However my PDF file doesn't show the updated data every-time I open the pop-up window. If I manually hit the F5 or refresh the page it shows the updated data. I tried something like this but to no avail.

window.open("http://something...").location.reload();

How can I refresh the pop-up window everytime it loads.

like image 975
Bibek Aryal Avatar asked Aug 23 '26 21:08

Bibek Aryal


1 Answers

You can append a timestamp into the url to avoid the browser cache

var url = "http:/myurl/myFile.pdf?"+ Date.now();
window.open(url);

for older browsers that doesn't support Date.now() you can use new Date().getTime();

like image 63
Vladu Ionut Avatar answered Aug 26 '26 12:08

Vladu Ionut



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!