Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up How to get Mac Address using javascript?

    Dear All,

    I want to get Mac address from mozilla firefox.My code is not working with firefox. Can anybody help?

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I don't think it's possible, and even if it is, it's more trouble than it's worth.

    If you are using this for authentication, there are better ways.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    you cannot. period. not even close. not even with a java liveconnect anymore.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Getting the address might be possible if the script is NOT running in a web browser. You'd need to check out the commands that are specific to the particular non-browser implementation of JavaScript to see if that platform supplies a way to do it.

    From within a browser you can't even get an IP address using JavaScript.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I think there are now webservices that will detect your IP and send it to you JSON. Perhaps there is one for MAC addresses.

    Still.. why?
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    Quote Originally Posted by WolfShade View Post
    I think there are now webservices that will detect your IP and send it to you JSON. Perhaps there is one for MAC addresses.
    no, impossible. A MAC address lives on the datalink layer while ip is a network layer protocol. in short: MAC info is not rout-able over TCP/IP/HTTP.
    your router knows your MAC, but your ISP doesn't (unless you use a registration-based wifi service, where you talk to there router), the router only gives out IP addresses in the packets.

    also, this isn't quite a service, and it's ancient, but it's reachable by JS: http://danml.com/pub/myip.asp
    Last edited by rnd me; 05-30-2013 at 09:56 PM.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #7
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Makes sense.. there really is no need for the internet to know the MAC address.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,658 Times in 4,620 Posts
    You almost surely *could* do this in MSIE.

    Naturally, the user would have to permit "unsafe scripting" and mark your site as a "trusted site".

    If nothing else, you could create a ".exe" that you could invoke from the browser, for example. Ugly as all get out ans inherently as safe as tissue paper, but...
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    Quote Originally Posted by Old Pedant View Post
    You almost surely *could* do this in MSIE.
    like getmac.exe or ipconfig /all |find "Physical" ?

    i'll be the wise guys and say javascript can't do that, maybe jscript can, but i don't think there is a way to get cmd output back to jscript beyond an errorlevel...

    maybe you know a trick we dont?
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,658 Times in 4,620 Posts
    Yep.

    Don't invoke getmac or ipconfig directly.

    Instead, invoke a ".cmd" file that does something like
    getmac > c:\somedir\macinfo.txt

    and then use Scripting.FileSystemObject to read the file.

    Used to do this all the time in another life (job). Haven't done it many many years. Security in IE is much tighter now, but that will still work once you get past the security.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •