MUI - 打开页面默认弹出键盘及返回关闭键盘
打开页面默认弹出键盘及返回关闭键盘
http://www.cnblogs.com/phillyx/
(function(keyboard) {
var openSoftKeyboard = function() {
if (mui.os.ios) {
var webView = plus.webview.currentWebview().nativeInstanceObject();
webView.plusCallMethod({
"setKeyboardDisplayRequiresUserAction": false
});
} else {
var Context = plus.android.importClass("android.content.Context");
var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
var main = plus.android.runtimeMainActivity();
var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
}
};
var autoFocus = function(obj) {
if (mui.os.ios) {
setTimeout(function() {
openSoftKeyboard();
obj.focus();
if (obj.tagName.toLowerCase() == 'textarea') {
moveEnd(obj);
}
}, 300);
} else {
//安卓的获取不到焦点,暂时不自动弹出
}
};
keyboard.autoFocus = autoFocus;
/**
* 预加载页面返回时为隐藏,不会自动关闭输入法,可以通过blur来关闭
* @param {Object} isRemoveValue
*/
function blur(isRemoveValue) {
var ac = document.activeElement;
ac.blur();
if (isRemoveValue && ac.value) {
ac.value = '';
}
};
keyboard.blur = blur;
/**
* @description ios下textarea.onfocus 时,默认在字首,添加该方法移动到尾部
* @param {Object} obj
*/
function moveEnd(obj) {
var len = obj.value.length;
if (document.selection) {
var sel = obj.createTextRange();
sel.moveStart('character', len);
sel.collapse();
sel.select();
} else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
obj.selectionStart = obj.selectionEnd = len;
}
};
// mui.plusReady(function() {
// if (mui.os.android) {
// Array.prototype.forEach.call(document.querySelectorAll(".mui-input-group input[type='text']"), function(ip) {
// ip.setAttribute('autofocus', 'autofocus');
// });
// }
// });
}(window.mykeyboard = {}));
MUI - 打开页面默认弹出键盘及返回关闭键盘的更多相关文章
- 打开页面默认弹出软键盘,同时兼容iOS和Android
// 示例1 open_soft_keyboard({ input: "#username" }); // 示例2 open_soft_keyboard({ input: 'inp ...
- 解决IE8打开默认弹出开发者工具的问题
有一次开发用ie调试后再次打开总是自动弹出ie开发者工具,而且在网页的上一层弹出.点击X关闭后再次打开还是会弹出! 找ie的设置也没有找到关闭的选项. 在网上搜了很多资料才找到解决的办法,在这里分享一 ...
- jsp页面制作弹出框
各种弹出页面的设计 [1.普通的弹出窗口] 其实代码非常简单: <SCRIPT LANGUAGE=javascript> <!-- window.open ('page.html') ...
- js关闭当前页面不弹出提示的方法
js关闭当前页面不弹出提示的方法 js关闭当前页面不弹出提示的方法 "window.opener=null;window.open('','_self','');window.close() ...
- Visual Studio 打开解决方案后 弹出框显示 "正在打开文件..." 迟迟没反应 的解决方法
Visual Studio 打开解决方案后 弹出框显示 "正在打开文件...",任务管理器的devenv进程又很正常,不会显示"未响应". 而IDE的左下角有个 ...
- CAD打开文件总是弹出要求选择字体怎么办
CAD打开文件总是弹出要求选择字体怎么办1.在C:\Documents and Settings\下搜索acad.fmp文件,双击用记事本打开acad.fmp文件,在最后添加内容,上面几行本来就有,不 ...
- Asp.Net下载页面,并弹出下载提示框
Asp.Net下载页面,并弹出下载提示框.在删除按钮里调用以下方法.
- js在关闭页面前弹出确认提示【转载】
最近项目中出现个bug,就是导出数据后,会提示确认导航,其实实际需求并不需要这个提示,可能是之前遗留的问题.查了下资料是在触发了onbeforeunload事件,那么剩下的就是代码组织问题了. 众所周 ...
- JavaScript:用JS实现加载页面前弹出模态框
用JS实现加载页面前弹出模态框 主要的JavaScript 代码是: <script> //加载模态框 $('#myModal').modal(); $(document).ready(f ...
随机推荐
- org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
从hibernate3升级到4应该会遇到 应该添加引用 <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-c3p0 ...
- leetcode 699. Falling Squares 线段树的实现
线段树实现.很多细节值得品味 都在注释里面了 class SegTree: def __init__(self,N,query_fn,update_fn): self.tree=[0]*(2*N+2) ...
- 2016年省赛 G Triple Nim
2016年省赛 G Triple Nimnim游戏,要求开始局面为先手必败,也就是异或和为0.如果n为奇数,二进制下最后一位只有两种可能1,1,1和1,0,0,显然异或和为1,所以方案数为0如果n为偶 ...
- LUOGU P1414 又是毕业季II
题目背景 "叮铃铃铃",随着高考最后一科结考铃声的敲响,三年青春时光顿时凝固于此刻.毕业的欣喜怎敌那离别的不舍,憧憬着未来仍毋忘逝去的歌.1000多个日夜的欢笑和泪水,全凝聚在毕业 ...
- bzoj 4373 算术天才⑨与等差数列——线段树+set
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4373 能形成公差为k的等差数列的条件:mx-mn=k*(r-l) && 差分 ...
- union 和order by 使用时排序不正确
静态专题和APP版专题(order by不起作用): [query] sql=(select sp_f13577,sp_f13576 from sp_t113 where url_1 not like ...
- web服务器--nginx简介
nginx 介绍Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务.Nginx是一款轻量级的Web 服务器/反向代理服务器及电 ...
- Codeforces 455B
题目链接 B. A Lot of Games time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 通信网络 ccf
试题编号: 201709-4 试题名称: 通信网络 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 某国的军队由N个部门组成,为了提高安全性,部门之间建立了M条通路,每条通路只 ...
- day18 16.dbcp连接池使用介绍
package cn.itcast.datasource; import java.io.FileInputStream; import java.sql.Connection; import jav ...