HTML
Program for prompt box |HTML|
Introduction
In the realm of web development, user interaction plays a pivotal role in creating engaging and dynamic experiences. One commonly used tool to interact with users is the JavaScript prompt box. In this blog post, we'll delve into the usage and implementation of prompt boxes in JavaScript, showcasing how they can enrich user engagement on web pages.
Code
<html>
<head>
<script type="text/javascript">
function show_prompt() {
var name = prompt("Please enter your name", "Anu");
if (name !== null && name !== "") {
document.write("<p>Hello " + name + "! How are you?</p>");
}
}
</script>
</head>
<body>
<input type="button" onClick="show_prompt()" value="Show"/>
</body>
</html>
Output
Conclusion
JavaScript prompt boxes are a valuable tool for enhancing user interaction and collecting user input on web pages. When used judiciously, they can contribute to creating more interactive and user-friendly experiences. However, it's essential to use them sparingly and ensure they complement the overall design and functionality of the webpage. With a solid understanding of prompt boxes, you can elevate the interactivity of your web applications and provide users with a more engaging experience. Happy coding!
Post a Comment
0 Comments