Javascript弹出对话框3种方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>三种弹出对话框的用法实例</title>
<script language=javascript >
function ale()
{
//这个基本没有什么说的,就是弹出一个提醒的对话框
alert("我敢保证,贾鹏你现在用的是演示一:提醒对话框");
}
function firm()
{
//利用对话框返回的值(true 或者 false)
if(confirm("你确信要转去贾鹏的博客?"))
{//如果是true ,那么就把页面转向ttp://hi.baidu.com/jiapeng8624237
location.href="http://hi.baidu.com/jiapeng8624237";
}
else
{
//否则说明下了,吼吼……
alert("你按了取消,那就是返回false");
}
}
function prom()
{
var name=prompt("请输入您的名字","YoungBaby提醒您在这里输入您的名字");//将输入的内容赋给变量 name ,
//这里需要注意的是,prompt有两个参数,前面是提示的话,后面是当对话框出来后,在对话框里的默认值
if(name)//如果返回的有内容
{
&nb
相关文档:
javascript中event.keycode
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space ......
看书的时候遇到这样一个问题,程序代码如下
var ob = function(){
var obj = this;
function fn1(){
alert( obj === window );//false
alert( this === window );//ture
}
this.fn2 = function() {
fn1();
}
}
当时很不明白fn1里面第二个alert的结果,为 ......
calcu() ----函数实现两个数相乘
document.write(); ---打印
document.calc.元素名.value; --获得表单的值
document.表单名。表单元素名。value 为表单赋值
定义函数:
function 名字()
{
//javaScript预语句
}
onClick="函数名";  ......
<html>
<body>
<script type="text/javascript">
//方法一
var num_arr= [];
for (var i = 0 ; i < 10 ; i ++)
{
num_arr[i] = i;
}
document.write(num_arr+'</br>');
//方法二
var obj_arr=new Array();
obj_arr[6]='ss';
document.write(obj_arr.len ......
Grouping Scripts 成组脚本
Since each <script> tag blocks the page from rendering during initial download, it's helpful to limit the total number of <script> tags contained in the page. This applies to both inline scripts as well as those in external files. Every time ......