문제

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");
}
도움이 되었습니까?

해결책

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

다른 팁

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top