Comment

Comment by KronisLV

On Chrome/Edge the page seems to open as expected and the PDF is previewed inline. On Firefox, a download immediately starts. Not a big issue or anything, just a slight difference in how browsers handle the page.

The HTML on the page responsible for this:

  <iframe class="pdf" loading="lazy" src="/pdfs/2023-01-24-how-to-lose-fp-at-work.pdf" title="How to Lose Functional Programming at Work - PDF">
  </iframe>
Here's approximately what I've used myself in the past as an alternative:

  <object data="/files/my-document.pdf#zoom=110" type="application/pdf" class="my-style-class" title="My PDF document">
    <!-- Fallback for older browsers that do not support the object tag -->
    <embed src="/files/my-document.pdf#zoom=110" type="application/pdf">
      <!-- Fallback in case PDF display of any sort is not supported -->
      <noembed>
        <span class="my-warning-class">
          It seems like your browser does not support displaying PDF files.
          You can download the file separately <a href="/files/my-document.pdf" download>here</a>.
        </span>
      </noembed>
    </embed>
  </object>
(not too clean of a solution, but seems to work okay in most cases)

The presentation/article itself is pretty nice, though. I really like the mentions of the human aspect of it all, how getting others onboard is quite important!

parent KronisLV 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton