JavaScript+Html+arduino ethernet

Help!
I want to integrate a javascript code with HTML in the Arduino and ethernet module ,even javascript code is simple, but it does not work!

client.println ();

Could you post a bit more code? From what you posted it will not work, you either need full javascript:

<script>
alert ('Motion Detection');
</script>

or if you are trying to send text to the browser:

client.println("<script>");
client.println("alert ('Motion Detection');");
client.println("</script>");

Thank you :slight_smile: it’s work , what about this code ? thank you :slight_smile:

and where i must save the sound ?

That should work (although it will only work in modern browsers and not IE) Have a look at this thread, maybe use howler.js if you struggle with the Audio object http://stackoverflow.com/questions/9419263/playing-audio-with-javascript

Also you should use the x.onplay = function(){...} event , onplaying only gets called if the audio was paused and restarted (which wont happen in your case)

The sound should be saved somewhere it is accessible from the browser: do you have a file directory structure? I would save it in the same place you are saving pictures, so if your pictures are in "/assets/images/" save the audio in "/assets/audio/alarme.wav" then you can do x = new Audio("/assets/audio/alarme.wav" ).

Why are you using the onplay event and not writing this?

var alarm = new Audio("alarme.wav");
alarm.play();
alert("Motion Detection");

you can also save the wav file on another web server.

x = new Audio("http://somedomain.com/alarme.wav")

Thanks for answers :slight_smile: ,
my code is :
client.println("");

this code is functional in browser but not in Arduino, the problem is that the Arduino does not know somefile alarme.wav, if I put the link from another audio file as http://s1download-universal-soundbank.com/ mp3 / sounds / 8506.mp3 the HTML page of the arduino becomes too heavy and did not work, so I have to find a solution to the arduino alarm file becomes known that I was recording in the computer.

rebhihatem1: if I put the link from another audio file as http://s1download-universal-soundbank.com/ mp3 / sounds / 8506.mp3 the HTML page of the arduino becomes too heavy and did not work, so I have to find a solution to the arduino alarm file becomes known that I was recording in the computer.

That makes no sense. The browser on your computer plays the sound not the arduino.

so what do you think ? why it’s not working :confused:

Try this instead

var audio = document.createElement('audio');
audio.src = 'http://www.wavsource.com/snds_2015-05-17_7234963463096348/animals/dog_puppy.wav';
audio.play();

Thanks :)