<nav class="mui-bar mui-bar-tab" style="display: none;" id="next">
<div id="hide">
<font id="replyDefault">随便说几句:</font>
</div>
<input id="say" type="text" style="color: #929292" onblur="shrink('onblur');" oninput="change();" placeholder="随便说几句">
</nav>
//弹出键盘操作
function softinput(id) {
var replyDefault = document.getElementById("replyDefault");
replyDefault.innerText = "回复:" + id.split("")[1];
commentId = id.split("_")[0];
//被回复者id
reply_userid = id.split("")[3];
inputType = "reply";
var imm, InputMethodManager;
var showSoftInputAndroid = function() {
var www = plus.nativeUI.showWaiting("呼出键盘中...", {
color: "#ff0000",
background: "rgba(0,0,0,0.7)",
});
var main = plus.android.runtimeMainActivity();
var Context = plus.android.importClass("android.content.Context");
InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
setTimeout(function() {
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
//此处可写具体逻辑设置获取焦点的input
var nav = document.getElementById("next");
nav.style.display = "block";
setTimeout(function() {
var say = document.getElementById("say");
say.value = "";
say.focus();
}, 300);
// var say = document.getElementById("say");
// //say.value = "";
// say.focus();
}, 500);
www.close();
};
var showSoftInputIos = function() {
var nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
nativeWebview.plusCallMethod({
"setKeyboardDisplayRequiresUserAction": false
});
var nav = document.getElementById("next");
nav.style.display = "inline";
var inputElem = document.getElementById("say");
inputElem.focus();
};
mui.plusReady(function() {
//开启安卓键盘
if (mui.os.android) {
showSoftInputAndroid();
} else {
showSoftInputIos();
}
var hide = document.getElementById("hide");
hide.style.display = "inline";
var say = document.getElementById("say");
say.placeholder = "";
});
}
从项目中copy出来的代码,可用。
4 个回复
我是巧克力
点击搜索输入框聚焦时,未弹出输入键盘,需再次点击才能弹出输入键盘
以下代码:
if($('#searchIpt').hasClass('mui-active')){
$('#searchIpt').removeClass('mui-active');
$('#searchKey').blur();
}
我也是遇到问题咯,在线等咯
yank90 (作者)
<nav class="mui-bar mui-bar-tab" style="display: none;" id="next">
<div id="hide">
<font id="replyDefault">随便说几句:</font>
</div>
<input id="say" type="text" style="color: #929292" onblur="shrink('onblur');" oninput="change();" placeholder="随便说几句">
//弹出键盘操作
function softinput(id) {
var replyDefault = document.getElementById("replyDefault");
replyDefault.innerText = "回复:" + id.split("")[1];
commentId = id.split("_")[0];
//被回复者id
reply_userid = id.split("")[3];
inputType = "reply";
var imm, InputMethodManager;
var showSoftInputAndroid = function() {
var www = plus.nativeUI.showWaiting("呼出键盘中...", {
color: "#ff0000",
background: "rgba(0,0,0,0.7)",
});
var main = plus.android.runtimeMainActivity();
var Context = plus.android.importClass("android.content.Context");
InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
setTimeout(function() {
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
//此处可写具体逻辑设置获取焦点的input
var nav = document.getElementById("next");
nav.style.display = "block";
setTimeout(function() {
var say = document.getElementById("say");
say.value = "";
say.focus();
}, 300);
// var say = document.getElementById("say");
// //say.value = "";
// say.focus();
}, 500);
www.close();
};
var showSoftInputIos = function() {
var nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
nativeWebview.plusCallMethod({
"setKeyboardDisplayRequiresUserAction": false
});
var nav = document.getElementById("next");
nav.style.display = "inline";
var inputElem = document.getElementById("say");
inputElem.focus();
};
mui.plusReady(function() {
//开启安卓键盘
if (mui.os.android) {
showSoftInputAndroid();
} else {
showSoftInputIos();
}
var hide = document.getElementById("hide");
hide.style.display = "inline";
var say = document.getElementById("say");
say.placeholder = "";
});
}
从项目中copy出来的代码,可用。
小白免
收藏了~
syll
mark一下