-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,431
  • 6
  • 46
  • 63
Dhwani
  • 7,484
  • 17
  • 78
  • 139

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
  • 11,533
  • 3
  • 29
  • 35