Is there a way to read the user's Page Display Resolution preference setting from javascript?
In order to ensure a predefined viewstate reaches the same location for any user, I need to check their display resolution, and modify the scrollposition value based on the resolution it was set with. This is a thing I need to do thousands of times, and obviously we can't use bookmarks.
Example: At halfway down an 11" page at 96dpi, pageViewY == ~528;
If the user has set their resolution to 110dpi, then it needs to be increased by 114%, or ~606.
I have been through the JS API and can find no reference to this value. I had tried using a script that would just set the viewstate to a given value, check the resulting position like so:
var zeroState = eval(viewState.toSource());
zeroState.pageViewZoom = 1;
zeroState.pageViewZoomType = 0;
zeroState.pageViewPageNum = 1;
zeroState.pageViewY = 3000 ;
viewState = eval(zeroState.toSource())
var testState = eval(viewState.toSource());
var n,diff;
n = testState.pageViewPageNum-1;
diff = 3000-(testState.pageViewY);
if(n > 0){
versionHeight = diff/n;
}
What happens in the console is that the resulting viewstate has its pagenumber increased (since 3000 exceeds the page height), and its pageViewY readjusted to the actual position. Ex: it will say page 3, yPos ~600 (3000 - 2 pages at ~1200 height)
But when the function is executed the resulting viewstate has not been modified, and reports as being on page 1 at yPos 3000. If I split the function up with a messy string of Timeouts, it works, but that's a kludge on a kludge. If there's some way to just read the user's display resolution, then that's the way to go.
