JS基本按鈕呼叫彈出視窗-03(按鈕呼叫js單純輸入對話合dialog-prompt)
資料來源:http://easonyo.pixnet.net/blog/post/25035463-javascript-%E5%BD%88%E5%87%BA%E5%B0%8F%E8%A6%96%E7%AA%97
<!DOCTYPE html>
<html>
<body>
<p>Click the button to demonstrate the prompt box.</p>
<button onclick=”myFunction()”>Try it</button>
<p id=”demo”></p>
<script>
function myFunction() {
var person = prompt(“Please enter your name”, “Harry Potter”);
if (person != null) {
document.getElementById(“demo”).innerHTML =
“Hello ” + person + “! How are you today?”;
}
}
</script>
</body>
</html>
|