5 Replies Latest reply: Jun 23, 2011 10:09 AM by 852650 RSS

    Browser user agent

      Hi Guys,

      does anyone know if it's possible to set the browser user agent?
      I want my application to be identified as a mobile device so that I get smaller log in screens on sites that identify by user agent.

      It would be nice to have :)
        • 1. Re: Browser user agent
          I assume you are talking about javafx script.
          In this case there is a bult in variable __PROFILE__.
          It is either one of "mobile", "desktop" or "browser" depending on which environment the script is executing in.

            If ("{__PROFILE__}" == "mobile") {   ……}
          • 2. Re: Browser user agent
            Ooops! Nope, I wasn't :)
            Javafx 2.0

            Browser browser = new Browser();
            • 3. Re: Browser user agent
              I am not entirely sure what you are asking for, but if it is JavaFX Mobile related, development on that has been postponed for the time being.

              If you are asking about manipulating the user-agent HTTP header that WebEngine uses when making requests, I can't see anything in the documentation that would allow that. But if all you want is a smaller display of a web page, you can always change WebView's scale or font scale settings.
              • 4. Re: Browser user agent
                Darryl Burke
                849647 wrote:
                Ooops! Nope, I wasn't :)
                Javafx 2.0

                Browser browser = new Browser();
                There's no class named <tt>Browser</tt> in JavaFX 2.0, so you would be better off asking the question wherever you got that class.

                • 5. Re: Browser user agent
                  D'Oh! You are correct. I was writing that from memory which has just proven itself to be ridiculously flawed!

                  I meant this:
                  final WebView browser = new WebView();
                  final WebEngine webEngine = new WebEngine("http://www.oracle.com");

                  Some websites check the user agent to determine if they are smart phones or not and reduce (compact) the size of the display/content for better usability. I thought it might be nice to try to take advantage of that if at all possible.

                  I guess it's not possible to set however. Going to http://whatsmyuseragent.com shows some nice information about the JavaFX web client.