Access screen height and width in a service worker -


i want service worker height , width of screen.

i've tried screen.height, self.innerheight, window.innerheight, seems service workers run on different context these undefined.

is there way access device information height , width within context of service worker?

service workers (and workers in general) can't access dom.

i can see 2 ways achieve want:

  1. store values in indexeddb (or in cache) in page , access them in worker;
  2. send values page service worker using postmessage.

obviously, can use first solution always, can't use second solution when service worker running , there isn't page open.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -