Is it possible to send a wake on LAN mand to a puter on a local network from a browser (no server side code). I have full control of the network. I would like to do it from a browser running on a tablet via wifi to a wired puter on the same LAN. I found some Node.JS JavaScript code: .js but I don't know if it will work from a browser.
Is it possible to send a wake on LAN mand to a puter on a local network from a browser (no server side code). I have full control of the network. I would like to do it from a browser running on a tablet via wifi to a wired puter on the same LAN. I found some Node.JS JavaScript code: https://github./agnat/node_wake_on_lan/blob/master/wake_on_lan.js but I don't know if it will work from a browser.
Share Improve this question asked May 27, 2016 at 19:42 Type955Type955 111 gold badge1 silver badge4 bronze badges4 Answers
Reset to default 3No, you can't.
The WoL needs to send a UDP broadcast package to the LAN. But browsers don't expose any API for UDP packages.
You need either server-side coding or browser plugins. You can write your own plugin that uses udp api.
Nodejs is specifically for writing server side code. you can not do this without a server. You can however buy a small puter like a raspberry pi to be your server.
You will have to:
- Buy a small simple puter like a raspberry pi or something similar.(this puter needs to be turned on all the time though)
- Install node on it.
- Write some javascript for the raspberry to take mands from the internet (like a browser extension) that can then send a local "magic packet" to the puter you want to wake up.
- Then make a client program. like a browser extension or an android app that can send http stuff to your server(raspberry pi).
For writing the server code you can use https://www.npmjs./package/node-wol which is a node library.
You need some form of interface between the system calls that would dispatch a 'magic packet' and your Javascript. It seems to me you wouldn't be able to do this without some form of backend witchcraft which is able to use system calls. Javascript, in my experience, is limited to performing things on the client side and being able to talk to, but not control, the server side.
But then again, I'm not a web developer. My limited web experience tells me that you need something to talk to your operating system, which will ultimately send the WoL magic packet.
Node is Server-side based, altought it uses Javascript Runtime Environment, it won't let you run something you wouldn't have permission to.
ZuLukas is pretty right. You can't do that with plain JavaScript code. You might find something right here: https://github./hypery2k/cordova-wol-plugin I bet it would be your best try without much effort.
You'll need to learn PhoneGap, then you'd build a Hybrid application. But, NOTICE that: JavaScript can't do that. Altough you'll code javascript to do it, it'll call native resources, and won't run in browser environment