1

I want to get the computer name using jquery. I tried using ActiveX Object but it will only run on IE browser. Is there is another way to get the computer name using jquery. I tried that code.

 var network = new ActiveXObject('WScript.Network');  
 alert(network.computerName); 

Can u any one help me..

user2979432
  • 83
  • 1
  • 1
  • 7
  • Even on that navigator it will probably be blocked on mostly computers. I don't think you would get that information without client extended code. Also define what you expect by computer name, host name, Wins name, etc. – Diego C Nascimento Oct 10 '17 at 03:59
  • 2
    no, there is no way a browser can access the underlying operating system like that at all – Jaromanda X Oct 10 '17 at 04:00
  • @guest271314 cleary if the user is already showing a solution for IE he is not working on a Firefox/Chrome extension. – Samuel Neff Oct 10 '17 at 04:14
  • @SamuelNeff You are ignoring _"I tried using ActiveX Object but it will only run on IE browser."_ OP is asking how the procedure can be accomplished, and used ie as an example of a browser accessing the local filesysystem or a shell. – guest271314 Oct 10 '17 at 04:16
  • @SamuelNeff `NativeMessaging` is available at edge browser https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/native-messaging – guest271314 Oct 10 '17 at 04:44
  • @guest271314 …in Edge extensions. Not in web pages. –  Oct 10 '17 at 06:18

2 Answers2

3

You can't. This information is not available to web sites.

The ActiveX approach outlined in your question won't even work in current versions of Internet Explorer, as the WScript.Network ActiveX object is not marked as safe for scripting.

  • The requirement is possible using `NativeMessaging` – guest271314 Oct 10 '17 at 04:04
  • @guest271314 That would involve installing a browser extension and/or a native application on the user's computer, which isn't something that a web site can do on its own. –  Oct 10 '17 at 04:05
  • "You can't" is not accurate as to the requirement. Protocol handler could also be utilized. – guest271314 Oct 10 '17 at 04:07
  • 2
    @guest271314 The implication is that the OP wants a method that will work in a "stock" web browser, without requiring the user to change browser security settings or install additional software / addons. –  Oct 10 '17 at 04:08
  • See OP at _"Is there is another way to get the computer name using jquery."_ . _"without requiring the user to change browser security settings or install additional software / addons"_ does not appear at Question. – guest271314 Oct 10 '17 at 04:09
  • 1
    @guest271314 the default for any question about the web, jquery, javascript would be in a browser unless specified otherwise. Your insistence that this is possible without clearly qualifying it "within an extension" is not helpful. – Samuel Neff Oct 10 '17 at 04:12
  • @SamuelNeff What are you talking about. The entire browser is an "extension" that is capable of communicating in multiple different protocols and using different application interfaces - including `WebAssembly` or even `ProcessingInstruction`. What a user chooses to do with the resources available in a modern browser is their choice, there are many choices available. The requirement is possible using a browser. – guest271314 Oct 10 '17 at 04:19
  • @guest271314 …are you sure you understand what we mean by "a browser extension"? –  Oct 10 '17 at 06:18
  • @duskwuff "a browser extension" does not appear at text of Question "Is there is another way" does appear at text of Question. – guest271314 Oct 10 '17 at 06:28
-1

Is there is another way to get the computer name

You can utilize NativeMessaging to achieve requirement at Firefox and Chromium, Chrome.

guest271314
  • 1
  • 15
  • 104
  • 177
  • 1
    This is only applicable for an extension. It cannot be used from a web page. – Samuel Neff Oct 10 '17 at 04:10
  • @SamuelNeff _"This is only applicable for an extension. It cannot be used from a web page"_ That is not correct. An extension can communicate with a web page. _"used from a web page"_ does not appear at Question. – guest271314 Oct 10 '17 at 04:12
  • Web page is very clearly the context of the question. – Samuel Neff Oct 10 '17 at 04:12
  • @user2979432 See https://wiki.mozilla.org/WebExtensions/Native_Messaging, https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/native-messaging, https://developer.chrome.com/apps/nativeMessaging, http://webassembly.org/, https://stackoverflow.com/questions/18134665/how-to-send-message-from-native-app-to-chrome-extension/ – guest271314 Oct 10 '17 at 04:33