User Agent
The user agent is a string of text that your browser sends with each web page request. The user agent string is how web sites can identify which web browser and operating system you are using. For example, when an iPhone visits a web page, this is what the user agent string might look like:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16
With the information provided by the user agent string, web page developers can customize their web pages for each web browser. They can also use it to determine whether the user visiting their web page is doing so with a "preferred" or supported web browser.
When you're developing or testing a web site, you may want to make sure that it properly detects and responds to specific browsers. The User Agent submenu lets you do that without having to install every possible browser that you want to test for (see Figure 4).
Figure 4 User Agent switcher
This submenu comes preconfigured with the user agent string for many of the most popular browsers. It's a very convenient way to test how your site responds to a number of different browsers. If you don't see the browser that you want to test with in the drop-down menu, the last option ("Other...") lets you enter the user agent string of your choice.
When you select a different web browser from the User Agent drop-down, the web page you are currently viewing will be requested again with the new user agent string of the browser that you specified, letting you see any browser-specific changes immediately.
Don't confuse switching the user agent string with browser emulation. Unfortunately, each web browser has different logic for how it interprets and renders web page content.
Switching the user agent string will let you test your browser-detection logic on your web site. If you look at the source code (we'll get to that in a little bit), you should be able to see the browser-specific differences in the content, if any. However, if it's important that your web page be tested with specific browsers, don't rely on this as a substitute.
There is one exception, however: iPhone testing. Because Safari is the very same browser running on the iPhone, you can be pretty confident that what you see in Safari on your Mac (or PC) is the same thing that your iPhone visitors will see, assuming that you are using the iPhone user agent string.