API request: Adding WebEngine.userAgent

Peter Zhelezniakov Peter.Zhelezniakov at oracle.com
Wed Oct 31 09:11:21 PDT 2012


I propose adding [userAgent] property to the WebEngine class. The new
property will be used for the value of the User-Agent HTTP header.

Rationale: HTTP servers sometimes check the User-Agent header to detect
browser they are talking to, and may serve different HTML to different
browsers. E.g. if a server detects an unknown browser it may send it
unoptimized, lowest-common-denominator version of a Web page, or page
optimized for mobile devices. This is why application developers may
want to pretend they're running Chrome or Safari or whatever.

This work is tracked under RT-22153. With 9 votes, it is the
most-voted-for WebView feature.

The new methods will read:

class javafx.scene.web.WebEngine {
     * Specifies user agent ID string. This string is the value of the
     * {@code User-Agent} HTTP header.
     * @defaultValue true
     * @since 8.0
    public final void setUserAgent(String value);
    public final String getUserAgent();
    public final StringProperty userAgentProperty();


More information about the openjfx-dev mailing list