{welcome to JS} 提示用户
2015-09-15 22:23
585 查看
1.通过prompt()提示用户作出响应
welcom5.html
<!DOCTYPE html> <html> <head> <title>Test prompt()</title> <h1>You can input your answer.</h1> </head> <body> <script src="script05.js"></script> </body> </html>
script05.js
var ans=prompt("Are you sure you want to do that?"); if(ans){ alert("You said "+ans); } else{ alert("You refused to answer."); }
运行结果
2.通过将重定向(redirect)功能嵌入代码
welcome6.html
<!DOCTYPE html> <html> <head> <title>Welcome to my site!</title> <script src = "script06.js"></script> </head> <body> <h2 class = "centerd"> <a href = "welcome5.html" id = "redirect">Welcome to my site...c'mon in!</a> </h2> </body> </html>
script06.js
window.onload = initAll; function initAll(){ document.getElementById("redirect").onclick = initRedirect; } function initRedirect(){ window.location="welcome5.html"; return false; }
运行结果
相关文章推荐
- JavaScript eval() 函数
- jsp知识点总结
- Javascript DOM
- JavaScript 对象
- JS设计模式之接口
- 浅谈——JSP九大内置对象与四大作用域
- H5 应用程序返回button的js代码设计,设计仿stack
- JavaScript 事件
- js中使用正则表达式(一)创建正则表达式的方式:正则对象方式和正则字面量方式
- jsp九大内置对象
- JSON数据的解析
- servlet&jsp的设计模式
- 《项目经验》--后台一般处理程序向前台JS文件传递JSON,JS解析JSON,将数据显示在界面--显示在DropDownList 或 显示在动态创建的table中
- 浅谈JS闭包
- jsp中session的生命周期
- jsp的4个作用域
- javascript中的function
- jsp的九大内置对象
- javascript判断非空
- JSP之Session生命周期