• Does this browser accept Cookies?
• Does this browser accept Flash?
• What processor chip type is in the computer hosting this browser?
• Will this browser run Java Applets?
• How wide is my window?
The answer ... if Javascript is enabled, which it usually is these days, is "via Javascript".
Javascript's
navigator object contains the answers to four out of the five questions above - there's a source code example
[here] and you can run that example
[here].
The Window width (and other things about the document that's displayed within the browser) are in the
document object; see
[here] for the source of an example, and run it
[here].
The questions I started with is "What is my IP address", and I've yet to find a full and proper answer to that one.
I can actually find out the IP address that the server sees me arriving from via PHP, looking at the
$_SERVER["REMOTE_ADDR"] variable, and writing an AJAX query. But that reports the IP address from the server's perspective, and not the IP address that's being used on our internal network behind our router. In other words, I'm connected to my local network at the moment as "192.168.200.199", but that's rewritten to "82.33.81.79" when I connect out to the Internet. My server reports back 82.33.81.79, but I really want to know in my browser that I'm at 192.168.200.199.
I'm rather afraid that the answer I'm going to come up with is that I can't easily find my local IP address; JavaScript is sandboxed for security reasons, so I'm not going to be able to have it run a local operating system command and return the results, nor am I going to be able to read a file that I leave on the disc of each local machine. Calling up a local server within the page via Javascript seems attractive, but again I find myself facing cross-site scripting issues. It appears that there *are* techniques around - such as
JSONP and
CORS - which would let my page call up a local server as well as the remote one, but that's a fudge which relies on me someone opening a security hole (see
Cross site Scripting, and I think the wise decision would be for me to look for a cleaner work around to meet my original requirement.
(written 2011-01-11, updated 2011-01-12)
Associated topics are indexed under
W508 - Web and Intranet - Which Browser? [2135] What features does this visitors browser support? (PHP) - (2009-04-22)
[1519] Flipping images on your web page - (2008-01-26)
W602 - Web and Intranet - Client Side Technologies [2628] An example of an injection attack using Javascript - (2010-02-08)
[2390] Dynamic / changing images on your web page - (2009-09-01)
[1814] Javascript/HTML example, dynamic server monitor - (2008-09-28)
[1813] Ajax - going Asyncronous and what it means - (2008-09-28)
[1812] Starting Ajax - easy example of browser calling up server data - (2008-09-27)
[1749] Using server side and client side programming together - (2008-08-11)
[1681] Adding a button to a web page to print the page - (2008-06-18)
[1322] Flash - is it available to your web page? - (2007-08-26)
[522] Javascript events - a good example - (2005-12-09)
[411] Javascript examples (some PHP and MySQL too) - (2005-08-13)
Some other Articles
Virtual Hosting with Apache http server - an overall scheme, and avoiding common pitfallsLua, Tcl, Python; Worldwide training classesNew Computers for delegates to useExtra courses - C and C++ How does your browser find out about itself?Burger me!Car Parking in Melksham - thoughts on the proposed scheme, and wider thoughts tooThe familiy is defunct. Long live the family.C++ - putting the language elements together into a programC++ objects - some short, single file demonstrations