my app has a submit feedback form. Is there a way to can capture the user's browser & version with jQuery and post that along with the form?
Thanks
my app has a submit feedback form. Is there a way to can capture the user's browser & version with jQuery and post that along with the form?
Thanks
JSON.stringify($.browser) // => {"webkit":true,"version":"535.11","safari":true}
// or whatever
This information is contained in the HTTP_USER_AGENT header and you can retrieve it on the server without having to try to figure it out on the client and then post it as part of your form data. Obviously the mechanism to extract this information depends on your server-side engine. This is the ASP.NET version but there will be an equivalent way to retrieve the header info in whatever server you're using. @mVChr's answer is useful when you are trying to determine the user agent on the client side if there is some browser-specific behaviour you are trying to implement.
If you post the info back in hidden form fields you are effectively duplicating information that is already in the request.
Create hidden form fields like:
<input type="hidden" name="browserVersion" id="browserVersion" value="" />
<input type="hidden" name="browserName" id="browserName" value="" />
Then use jQuery to populate it.
var browserObj = JSON.stringify($.browser); //@mVChr
$("#browserVersion").val(browserObj.version);
...
and so forth!