lib/capturejs.js
function createPageHandler(page) {
        if (DEBUG && !page.phantom) inspectArgs("createPageHandler: ", page);

        phPage = page;
        var matches;

        if (option.viewportsize) {
            matches = option.viewportsize.match(/^(\d+)x(\d+)$/);
            if (matches !== null) {
                page.property("viewportSize", {width: matches[1], height: matches[2]});
            }
        }

        if (option.cliprect) {
            matches = option.cliprect.match(/^(\d+)x(\d+)x(\d+)x(\d+)$/);
            if (matches !== null) {
                page.setting("clipRect", {top: matches[1], left: matches[2],
                    width: matches[3], height: matches[4]});
            }
        }

        if (option["user-agent"]) {
            page.setting("userAgent", option["user-agent"]);
        }

        if (option.zoomfactor) {
            page.setting("zoomFactor", parseFloat(option.zoomfactor));
        }

        if (option.timeout) {
            timer = setTimeout(function () {
                var err = `capturejs: cannot access ${option.uri}: request timed out`;
                console.error(err);
                phInstance.exit();
                process.nextTick(function () { callback(err) });
            }, +option.timeout);
        }

        return page.open(option.uri);
    }
function createPageHandler(page) {
        if (DEBUG && !page.phantom) inspectArgs("createPageHandler: ", page);

        phPage = page;
        var matches;

        if (option.viewportsize) {
            matches = option.viewportsize.match(/^(\d+)x(\d+)$/);
            if (matches !== null) {
                page.property("viewportSize", {width: matches[1], height: matches[2]});
            }
        }

        if (option.cliprect) {
            matches = option.cliprect.match(/^(\d+)x(\d+)x(\d+)x(\d+)$/);
            if (matches !== null) {
                page.setting("clipRect", {top: matches[1], left: matches[2],
                    width: matches[3], height: matches[4]});
            }
        }

        if (option["user-agent"]) {
            page.setting("userAgent", option["user-agent"]);
        }

        if (option.zoomfactor) {
            page.setting("zoomFactor", parseFloat(option.zoomfactor));
        }

        if (option.timeout) {
            timer = setTimeout(function () {
                var err = `capturejs: cannot access ${option.uri}: request timed out`;
                console.error(err);
                phInstance.exit();
                process.nextTick(function () { callback(err) });
            }, +option.timeout);
        }

        return page.open(option.uri);
    }
function createPageHandler ( page ) { if ( DEBUG && ! page . phantom ) inspectArgs ( "createPageHandler: " , page ) ; phPage = page ; var matches ; if ( option . viewportsize ) { matches = option . viewportsize . match ( / ^(\d+)x(\d+)$ / ) ; if ( matches !== null ) { page . property ( "viewportSize" , { width : matches [ 1 ] , height : matches [ 2 ] } ) ; } } if ( option . cliprect ) { matches = option . cliprect . match ( / ^(\d+)x(\d+)x(\d+)x(\d+)$ / ) ; if ( matches !== null ) { page . setting ( "clipRect" , { top : matches [ 1 ] , left : matches [ 2 ] , width : matches [ 3 ] , height : matches [ 4 ] } ) ; } } if ( option [ "user-agent" ] ) { page . setting ( "userAgent" , option [ "user-agent" ] ) ; } if ( option . zoomfactor ) { page . setting ( "zoomFactor" , parseFloat ( option . zoomfactor ) ) ; } if ( option . timeout ) { timer = setTimeout ( function ( ) { var err = ` ${ option . uri } ` ; console . error ( err ) ; phInstance . exit ( ) ; process . nextTick ( function ( ) { callback ( err ) } ) ; } , + option . timeout ) ; } return page . open ( option . uri ) ; }
Configure page settings then open a new page in PhantomJS.
Configure page settings then open a new page in PhantomJS .