网页上面实现JavaScript 消息框的技巧
1、用java做一个有折行的警示框效果。+ '\n' 实现了分行的效果。<html><head><script type="text/javascript">function 双行警示_alert(){alert("你的输入错误了," + '\n' + "请重新输入。")}</script></head><body><input type="button" onclick="双行警示_alert()" value="警告操作" /></body></html>
2、在网页上面做一个确认框,并根据不同的选择结果进行窗口的回复。<html>挢旗扦渌;<head><script type="text/javascript">function 展示确认_confirm(){var r=confirm("请选择");if (r==true) { alert("您选择正确了"); }else { alert("您的选择取消了"); }}</script></head><body><input type="button" onclick="展示确认_confirm()" value="呈现确认窗口" /></body></html>
3、function 展示确认_confirm() 让确认窗口可以弹出,而 if else语句让访问者可以进行不同结果的选择。
4、做一个提示框,并根据输入内容把结果呈现在网页上面。思路:声明一个消息框代码,使用一个选择代码if else,需要定义一个变量。
5、整个提示框效果的java代码流程。<html><head><script type=媪青怍牙"text/javascript">function 随机_prompt() { var 姓名=prompt("您是?","您的名字请输入") if ( 姓名!=null && 姓名!="") { document.write("今天不错!" + 姓名 + " 天天快乐") } }</script></head><body><input type="button" onclick="随机_prompt()" value="点击一下" /></body></html>
6、当提示框弹出后,我们进行了相关文本输入,最后有了一个网页的文本呈现。