87,997
社区成员




<html>
<head></head>
<script>
function setName(obj){
var value = window.prompt("用户名:", "yourname");
var username = document.getElementById("username");
if(!value){username.value="";}
else username.value = value;
}
</script>
<body>
<input type="text" id="username" readonly/>
<input type="button" value="输入" onclick="setName(this)">
</body>
</html>
楼主试试这个。。。
<html>
<head></head>
<script>
function setName(obj){
var value = window.prompt("用户名:", "yourname");
var username = document.getElementById("username");
username.value = value;
}
</script>
<body>
<input type="text" id="username" readonly/>
<input type="button" value="输入" onclick="setName(this)">
</body>
</html>
if (prompt("input", "") === null) {
/* todo : cancel */
return;
}
if (prompt("input", "") == null) {
alert('cancel');
}