prompt(message, default)
<html>
<head>
<script type = "text/javascript">
function fun() {
prompt ("This is a prompt box", "Hello world");
}
</script>
</head>
<body>
<p> Click the following button to see the effect </p>
<form>
<input type = "button" value = "Click me" onclick = "fun();" />
</form>
</body>
</html>
Click the following button to see the effect
<!DOCTYPE html>
<html>
<head>
<title>
JavaScript prompt() method
</title>
<script>
function fun() {
var a = prompt("Enter some text", "the bianchenghao6.com");
if (a != null) {
document.getElementById("para").innerHTML = "Welcome to " + a;
}
}
</script>
</head>
<body style = "text-align: center;">
<p style = "color: red;">
Hello World
</p>
<p>
Example of the JavaScript prompt() method
</p>
<button onclick = "fun()">
Click me
</button>
<p id = "para"></p>
</body>
</html>
Hello World
Example of the JavaScript prompt() method
<html>
<head>
<script type = "text/javascript">
function fun() {
prompt(" Hello World \n Welcome to the bianchenghao6.com \n This is a prompt box ");
}
</script>
</head>
<body>
<p> Click the following button to see the effect </p>
<form>
<input type = "button" value = "Click me" onclick = "fun();" />
</form>
</body>
</html>
Click the following button to see the effect