There is no support for that right now. I think it's a good feature to
have, please file a feature request in the issue tracker.
Meanwhile, try to use the onInitialized handler to "fake" the screen
object, one existing example from mine:
http://ariya.ofilabs.com/2011/10/detecting-browser-sniffing-2.html.
Thank you!
Best regards,
--
Ariya Hidayat, http://ariya.ofilabs.com
OTOH if onInitialized works well for such uses cases, then there is no
really a desperate need to construct a new public API.
Regards,
They are different. In the normal desktop, viewport is the browser
window while screen is the monitor.
In all cases, override of the screen object might be sufficient and
there is no need for the API.
> And while the viewport has actual effects on the browser rendered surface,
> screen really doesn't (we don't have one :) ).
The effect will be indirect, as in the case with e.g. jQuery Mobile.
I assume you haven't redefine completely the screen object, it won't
work that way.
Here is a complete example:
var page = require('webpage').create();
page.onInitialized = function () {
page.evaluate(function () {
(function () {
window.screen = {
width: 1000,
height: 500
};
})();
});
};
console.log(JSON.stringify(page.evaluate(function () { return
window.screen })));
phantom.exit();