Skip to content

Question: feature detection? #86

Description

@doedje

What feature should I check for to see if Viewer.js will work in my target browser?
Is there a check in modernizr I can use?

I want to do something like this:

// pseudo code
if (modernizr.someCheck) {
  // show the document with Viewer.js
} else {
  // use old viewer to show the document
}

(and why is this not properly documented?)

Activity

  1. kossebau commented on Aug 28, 2014

    @kossebau
    Contributor

    There is no such check yet possible. Agreed that it would be good to have that. But for now only a TODO.
    Thanks for the hint to modernizr, looks interesting.

  2. doedje commented on Aug 28, 2014

    @doedje
    Author

    I'll check for Canvas since it is needed for PDF.js (see: https://github.com/mozilla/pdf.js/wiki/Required-Browser-Features)

  3. doedje commented on Sep 4, 2014

    @doedje
    Author

    Too bad, IE9 does have a canvas but is not showing my document. I had to do a better test and wanted to share the results with you (and other Viewer.js users).

    First I mention the sites I used to come to my results:
    http://mozilla.github.io/pdf.js/features/ - A testpage that shows you exactly what features are supported by your browser, what the impact of missing this feature is on the correct functioning of PDF.js and whether it was possible to emulate the feature in case it is missing.

    http://modernizr.github.io/Modernizr/test/index.html - A testpage of all features detectable with Modernizr.

    https://www.browserleaks.com/modernizr - Also testpage of Modernizr features, but a bit better readable. But since it is maintained by a third party it might fall behind.

    With those pages open on different browsers that do and do not support Viewer.js I was able to come to the following test to build a fallback option for Viewer.js:

    if (Modernizr.canvas && Modernizr.webworkers) {
       // show the document with Viewer.js
    } else {
      // use old viewer to show the document
    }
    

    The browsers we wanted supported should have the following features:

    When needed it can be expanded in the future with the following tests:

    Using:
    Modernizr 2.8.3 (Custom Build) | MIT & BSD
    Build: http://modernizr.com/download/#-canvas-webworkers-testprop-testallprops-domprefixes-dataview_api-file_api

  4. doedje commented on Apr 21, 2015

    @doedje
    Author

    This week I discovered (or rather collegues of me did) that REALLY old browsers: Safari 5.1.1 and Firefox 12 do pass the modernizr tests I used but do not properly display Viewer.js (we see the interface but no document)
    I will look into the why and maybe build a more specific test, but with all those browsers (desktop, phones and tablets) it is a pain in the a.......... ;)

  5. vandenoever commented on Apr 21, 2015

    @vandenoever
    Member

    On Tuesday 21 April 2015 04:02:31 Remy Blom wrote:

    This week I discovered (or rather collegues of me did) that REALLY old
    browsers: Safari 5.1.1 and Firefox 12 do pass the modernizr tests I used
    but do not properly display Viewer.js (we see the interface but no
    document) I will look into the why and maybe build a more specific test,
    but with all those browsers (desktop, phones and tablets) it is a pain in
    the a.......... ;)

    If you can come up with a reliable way to detect if browser will support
    viewerjs, we can add a warning message when the viewer is loaded in an
    unsupported browser.

    Cheers,
    Jos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions