我遇到了使用onClick事件的JS / HTML问题...
在Android手机GT-I8190N(Jelly Bean Android)上我无法触发onClick事件或自动onchange事件(如JS无效)
<!DOCTYPE html>
<html>
<head>
<title>
Remote Control Panel
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script type="text/javascript">
function doThat() {
var eSelect = document.getElementById('0');
var radioF4 = document.getElementById('01');
var msgboxTxt = document.getElementById('02');
if(eSelect.selectedIndex === 1) {
radioF4.style = "";
} else {
radioF4.style = "visibility: hidden;";
}
if (eSelect.selectedIndex === 0) {
msgboxTxt.style = "";
} else {
msgboxTxt.style = "visibility: hidden;";
}
}
window.onload = doThat();
</script>
</head>
<body>
<center>
<h1>
Remote Control Panel
</h1>
<br>
<br><br>
<h3>Command:</h3>
<form action="" method="POST">
<select name="hh" id="0">
<option selected="selected" value="msgbox" id="1" name="1">thing 1</option>
<option value="altf4" id="2" name="2">thing 2</option>
<option value="illuminati" id="3" name="3">thing 3</option>
<option value="endilluminati" id="4" name="4">thing 4</option>
<option value="blkmouse" id="5" name="5">thing 5</option>
<option value="unblkmouse" id="6" name="6">thing 6</option>
</select>
<br>
<div>
<div style="visibility: hidden;" id="01" name="01">
<input type="radio" name="01" value="enter">Send enter?
</div>
<div style="" id="02" name="02">
MessageBox Text:
<input type="text" name="msgboxtext">
</div>
<i style="cursor: pointer;" class="fa fa-refresh" onClick="doThat()" ontouchstart="doThat();"></i><a href="javascript:doThat()">eeeh</a>
</div>
<input type="submit" name="submit" value="Send command!">
</form>
</center>
</body>
</html>
这也不起作用(只是脚本)
<script type="text/javascript">
window.onload = function() {
var eSelect = document.getElementById('0');
var radioF4 = document.getElementById('01');
var msgboxTxt = document.getElementById('02');
eSelect.onchange = function() {
if(eSelect.selectedIndex === 1) {
radioF4.style = "";
} else {
radioF4.style = "visibility: hidden;";
}
if (eSelect.selectedIndex === 0) {
msgboxTxt.style = "";
} else {
msgboxTxt.style = "visibility: hidden;";
}
}
}
</script>
单选按钮刚刚出现在Android上,但它会出现在我的笔记本电脑上。