mirror of
https://github.com/ariya/phantomjs.git
synced 2024-08-15 15:50:34 +03:00
The DOM structure of the page that is retrieved by useragent.js has changed since the example was last updated, and the selector for the user agent value no longer exists. This causes a TypeError to be output to the user when running the example. This updates the example to use a selector that exists on the page. https://github.com/ariya/phantomjs/issues/15392
16 lines
490 B
JavaScript
16 lines
490 B
JavaScript
"use strict";
|
|
var page = require('webpage').create();
|
|
console.log('The default user agent is ' + page.settings.userAgent);
|
|
page.settings.userAgent = 'SpecialAgent';
|
|
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;
|
|
});
|
|
console.log(ua);
|
|
}
|
|
phantom.exit();
|
|
});
|