Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
60
rated 0 times [  63] [ 3]  / answers: 1 / hits: 46726  / 12 Years ago, wed, november 21, 2012, 12:00:00

I've two event handlers bound to an anchor tag: one for focus and blur.



The handlers fire on desktop, but in iphone and ipad only focus is fired correctly. Blur is not fired if I click outside the anchor tag (blur fires only when I click some other form elements in the page):



    $(a).focus(function(){
console.log(focus fired);
});

$(a).blur(function(){
console.log(blur fired);
});


HTML:



<html>
<form>
<a href=#>test link</a>
<div>
<input type=text title= size=38 value= id=lname1 name= class=text>
</div>
<div style=padding:100px>
<p>test content</p>
</div>
</form>
</html>

More From » iphone

 Answers
55

If an anchor has any events attached, the first tap on it in iOS causes the anchor to be put into the hover state, and focused. A tap away removes the hover state, but the link remains focused. This is by design. To properly control an application on iOS, you need to implement touch-based events and react to those instead of desktop ones.



There is a complete guide to using Javascript events in WebKit on iOS.


[#81879] Monday, November 19, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryanulyssesb

Total Points: 91
Total Questions: 105
Total Answers: 102

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
ryanulyssesb questions
Sat, Mar 20, 21, 00:00, 3 Years ago
Mon, Sep 14, 20, 00:00, 4 Years ago
Mon, Mar 9, 20, 00:00, 4 Years ago
Sun, Jul 7, 19, 00:00, 5 Years ago
;