9

Why Google Viewer sometimes is opening a blank page instead of open the PDF file?

I could simulate it using this code. It doesn't happen every time. It will be necessary to click on the Google Viewer button few times.

I could simulate it on Edge and Chrome.

blank tab

enter image description here

Pay attention to the two tabs after the tab title "Sem títlulo". They opened the PDF file perfectly. However, the tab with the title "Sem título" did not open the PDF.

EDIT

I'm using google docs viewer https://docs.google.com/viewer.

Gus
  • 856
  • 1
  • 8
  • 24
  • could be a bug the browsers with stalling loading tabs. nothing to do with your code however. – Daniel A. White Jun 25 '20 at 19:51
  • That's what [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) does... unless you configure it not to with the windowname argument. – Scott Marcus Jun 25 '20 at 20:19
  • 2
    @Scott Marcus: I believe the issue is, that the pdf/window itself sometimes is blank, not that it opens in a new tab. Click it a few times and you will see (like each third for me). – Lain Jun 25 '20 at 20:23

1 Answers1

4

I try to test your code on the MS Edge legacy browser, MS Edge (Chromium) browser, Google Chrome browser, and Firefox browser.

I can reproduce the issue on all 4 browsers. So we can say that this is not a specific browser related issue.

I noticed that you are using Google docs viewer to display the PDF.

https://docs.google.com/viewer?

I try to display the PDF directly in the browser and found that it is working fine in every browser.

Test code:

<a href="javascript:void(0);" onclick="javascipt:window.open('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf');" class="popup">Click to open PDF</a>

Here is the test results in MS Edge (Chromium) browser.

enter image description here

So it looks like there is some issue with the Google docs viewer. You can try to provide feedback to Google about this issue.

To fix the issue in your code, you can try to directly display the PDF file as I show you in my sample code. You can notice that performance is also better.

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • 1
    It makes sense. I added a test using Microsoft viewer and it worked. I can´t change it at the moment because it opens other extensions. – Gus Jun 26 '20 at 12:31
  • 3
    I try to search further and it looks like a known issue with the Google docs viewer. I found a similar thread on their support forum. https://support.google.com/docs/thread/34309483?hl=en You can try to provide your feedback there. – Deepak-MSFT Jun 29 '20 at 05:14
  • 1
    Hi, I opened a thread on their support too. I've not received any feedback yet. I upvoted and subscribed there. Thank you. – Gus Jun 29 '20 at 13:23