最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript touchend event will not fire on Android - Stack Overflow

programmeradmin0浏览0评论

I'm trying to use the touchend (or the taphold event, both wont fire) as specified by jquery mobile. I'm developping an app for android using the phonegap platform. My AVD runs Android 4.0.3, and my phonegap version is 1.3.0.

As im using phonegap, i'm coding in javascript, and the objective is to recuperate the text selected by the user after a longpress on a word with the following code.

var selectAction = function(){
    LOGGER.log('event.js : selectAction');
};

function selectMobile(ponent){
    ponent.addEventListener('touchend',selectAction,false);
}

It actually works fine, if I tap relatively quickly, the event will fire up and I can get the log message. However, a rapid touch will not select text (I have more code taking the selected text but this is not the issue)

When a user long presses in Android, a default ''Action Menu'' pops up, and this seems to block further events from firing up. Because of that, I never get into my selectAction when actual text is selected.

Does anybody know how to properly get selected text in an html/javascript on an Android platform ?

Thank you very much.

I'm trying to use the touchend (or the taphold event, both wont fire) as specified by jquery mobile. I'm developping an app for android using the phonegap platform. My AVD runs Android 4.0.3, and my phonegap version is 1.3.0.

As im using phonegap, i'm coding in javascript, and the objective is to recuperate the text selected by the user after a longpress on a word with the following code.

var selectAction = function(){
    LOGGER.log('event.js : selectAction');
};

function selectMobile(ponent){
    ponent.addEventListener('touchend',selectAction,false);
}

It actually works fine, if I tap relatively quickly, the event will fire up and I can get the log message. However, a rapid touch will not select text (I have more code taking the selected text but this is not the issue)

When a user long presses in Android, a default ''Action Menu'' pops up, and this seems to block further events from firing up. Because of that, I never get into my selectAction when actual text is selected.

Does anybody know how to properly get selected text in an html/javascript on an Android platform ?

Thank you very much.

Share Improve this question asked Feb 20, 2012 at 20:05 JulzJulz 1571 gold badge3 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

It's could be related to below bug. http://code.google./p/android/issues/detail?id=19827

try catch touchmove and call e.preventDefault()

发布评论

评论列表(0)

  1. 暂无评论