Question

I used this code in Arduino but I don't how this onmousedown works and what is meant location.href=/?off13 in this code:

client.println("<input type=button value=OFF style='width:150px' onmousedown=location.href='/?off13;'>");
if(readString.indexOf('12') >0)//checks for 6
{
    digitalWrite(7, HIGH);    // set pin 7 high
    Serial.println("Led 7 On");
}

if(readString.indexOf('13') >0)//checks for 7
{
    digitalWrite(7, LOW);    // set pin 7 low
    Serial.println("Led 7 Off");
}
Was it helpful?

Solution

The onmousedown event occurs when a user presses a mouse button over an element.

<p onmousedown="myFunction()">Click the text!</p>

The onmousedown attribute is similar to the onclick attribute, but differs in that the event is triggered the moment the mouse button is pressed on the element, rather than at the point at which the mouse button is released (onclick is effectively a combination of onmousedown and onmouseup event on the element)

The href property sets or returns the entire URL of the current page.

location.href=URL

OTHER TIPS

Following link will be useful for you to understand OnMouseDown event :

click, mousedown, mouseup, dblclick

Best of luck....

And in your code, location.href=/?off13 is passing value 13 to query string...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top