tags:

views:

59

answers:

3

Hi folks,

Could you please tell me, if it's possible to read Environment Variables using Javascript from a page running on Firefox.

+4  A: 

No. JavaScript is sandboxed to prevent this sort of thing.

Matt Ball
+1  A: 

Short answer: No.

Long answer: Maybe. If you mean system environment variables, there isn't (that I'm aware of) any way to do that via straight JavaScript. You can access a number of system information through JavaScript though. Check this page out for some examples:

http://www.docsteve.com/DocSteve/Samples/JS/javascript_env.html

This shows how to get the underlying OS/platform, Depending on exactly what you're looking for, this may not work. It's possible via other methods, like creating an ActiveX object and using that. However, this requires additional steps on the user end (like installing/authorizing ActiveX).

I think this is a security feature, separating the system from the browser, therefore it can be difficult (or impossible, depending on your requirements).

(Edit: First answer!)

Josh
[Firefox doesn't support ActiveX.](http://support.mozilla.com/en-US/kb/ActiveX)
Matt Ball
Thanks for the help Josh. @Bears will eat you, you are right FF doenst support ActiveX, so I am out of luck here I guess
t3ch
While FF doesn't natively support ActiveX, I've personally used ActiveX within FF before via an add-on. This was a while ago, 1.x, so maybe newer FF versions removed that capability.
Josh
A: 

Which Environment Variable would you need to access?

Mike Ratcliffe
Some OS or machine based variables
t3ch
Is it possible to get the ip address of the machine where broswer is running. Like in java you can use getRemoteAddr();
t3ch
@t3ch: no, it isn't. Think: HUGE SECURITY HOLES. Why are you trying to do this with JavaScript, anyway?
Matt Ball