I have a mobile template with a login form which is ajax / url hash based browsing. If on an iphone a user clicks the "go" button on the iphone keyboard the ajax authenticates / logs them in and then loads the next page inside another div and hides the current login form div.
The problem is, on an iphone the keyboard is still popped up. Is there anyway to unfocus a textbox element via javascript?
Use the blur() method to remove the focus from an element, e.g. input. blur() . If you need to remove the focus from the currently active element without selecting it, call the blur method on the activeElement property - document.
Use HTML5 Placeholder attribute, you don't need to use any js. To disable autofocus on all input elements use this. Actually there is no autofocus, what are you asking.
The HTMLElement. blur() method removes keyboard focus from the current element.
The blur() method removes focus from an element.
This is what I used when .blur()
didn't want to be my friend
function blurAll(){ var tmp = document.createElement("input"); document.body.appendChild(tmp); tmp.focus(); document.body.removeChild(tmp); }
Use the blur()
method or try setting the focus on another element like a link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With