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:
- store values in indexeddb (or in cache) in page , access them in worker;
- 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
Post a Comment