1
1
mirror of https://github.com/ariya/phantomjs.git synced 2024-09-11 04:46:09 +03:00
phantomjs/examples/useragent.js

16 lines
490 B
JavaScript
Raw Normal View History

"use strict";
var page = require('webpage').create();
console.log('The default user agent is ' + page.settings.userAgent);
page.settings.userAgent = 'SpecialAgent';
2011-05-26 01:29:20 +04:00
page.open('http://www.httpuseragent.org', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var ua = page.evaluate(function () {
return document.getElementById('qua').value;
2011-05-26 01:29:20 +04:00
});
console.log(ua);
}
phantom.exit();
2011-05-26 01:29:20 +04:00
});