I've been attempting to retrieve information about the visitors' browser on my website. Unfortunately, the return I receive for each parameter is showing as 'undefined.'
Below is the code I'm using (this is linked as an external JS file in the HTML head):
function navigatorInfo(){
alert("YOUR COMPUTER INFO SIR: \n\nBrowser Code Name: " + navigator.appCodeName + "\nBrowser Name: " + navigator.appName + "\nBrowser Version: " + navigator.appVersion + "\nCookies Enabled: " + navigator.cookieEnabled + "\nPlatform: " + navigator.platform + "\nUser-agent header: " + navigator.userAgent + "\nUser-agent language: " + navigator.systemLanguage );
}
I've called the function in the HTML body like so:
<input type="button" onclick="navigatorInfo()" value="Click Here to Retrieve Your Computer Info!"/>
The data returned appears as:
YOUR COMPUTER INFO SIR:
Browser Code Name: undefined
Browser Name: undefined
Browser Version: undefined
Cookies Enabled: undefined
Platform: undefined
User-agent header: undefined
User-agent language: undefined
Any suggestions or thoughts?
Update: Following the suggestion, I renamed the function to navigatorInfo and received this data upon retrieval:
Browser Code Name: Mozilla Browser Name: Netscape Browser Version: 5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13 Cookies Enabled: true Platform: MacIntel User-agent header: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13 User-agent language: undefined.
However, despite using a Safari browser, the Browser that was returned is identified as Mozilla...
UPDATE: Got it figured out now, thanks for the assistance.... http://www.quirksmode.org/js/detect.html