Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to default to browser 'Reader View' mode via CSS or Javascript?

All modern web browsers now have a 'Reader View' mode available. Is it possible, via CSS and/or Javascript, to tell browsers to automatically use the 'Reader View' version on mobile devices that have up to 480px screen width?

I just don't want to create a mobile version of the site since the 'Reader View' version works perfect on mobile devices (that have 320px-480px screen width).

PS. I'm not looking for the information when the Reader View icon is triggered - I want to force the Reader View mode on mobile devices that have less than 480px screen width. Besides, the Reader View mode is available in other browsers too (not only in Firefox).

like image 582
NonCoder Avatar asked Jul 11 '15 03:07

NonCoder


People also ask

How do I put my browser in reader mode?

Open the Chrome browser on your computer, type chrome://flags in the address bar, and hit Enter. Search for “Reader Mode” in the text box at the top and enable the flag titled “Enable Reader Mode.” After enabling the flag, click the “Relaunch” button at the bottom of the screen to apply the changes.

Which browser has a reading mode?

Chrome and Firefox both come with a reader mode to help declutter pages. Here's how to use the feature in both browsers. Some websites are full of ads, graphics, videos, banners, and other superfluous clutter.

How does browser reader mode work?

Most web browsers have a “reader mode" that strips away non-essential content, providing a simpler text-based presentation. Toggling reader mode typically removes ads, formatting, and other distracting elements, leaving behind the text (and in most cases, images).

Can web browser read HTML?

Every major Internet browser allows users to view any web page's HTML source code.


1 Answers

The URL of the Reader mode is: about:reader?url=https%3A%2F%2F.... The url parameter must be URL encoded.

I tried changing the page location to that URL and got an access denied error using Firefox 68.0.1.

I also tried to create a link, it fails without error. Mozilla doesn't seem to be willing to give access to it.

Instead, you can reuse their implementation which uses Readability. To run it only when on mobile you can check those questions:

  • Responsive css styles on mobile devices ONLY
  • What is the best way to detect a mobile device? - this answer in particular https://stackoverflow.com/a/10364620/2223027
like image 121
pyb Avatar answered Oct 16 '22 23:10

pyb