-2

I want to check if browser support pdf viewer or not before anything loads on page and then if pdf viewer is not enable, I want to display alert pdf viewer is not enable and redirect to some other page.

I tried

window.onload = function () {}

$(document).ready(function () { });

$( window ).load(function() { });

but it still shows page in background. I do not want to display page until it is confirmed that pdf viewer is installed. Please help.

Albzi
  • 15,201
  • 5
  • 43
  • 61
Dhwani
  • 7,186
  • 16
  • 73
  • 137

1 Answers1

0

If it is enough to just hide the page, the you can put style="display: none" on root element and then if PDF is enabled you just show it

HTML

<html><head></head><body>
     <span id="hideItAll" style="display: none">
         ... Your content goes here ...
     </span>
</body>

And in javascript you just show it up

if( pdf ) document.getElementById('hideItAll').style.display = ''; else alert( ... );

Other approach is to redirect user on page with content after PDF check is ok

SergeS
  • 10,948
  • 2
  • 28
  • 35