Javascript设置广告和时间表和数组的学习

 <html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<hr>
<h1>2:使用window.open() 是一个广告?</h1>
<input type="submit" onclick="" value="关闭"/>
<script language="javascript">
for(var i=0;i<5;i++){
var w=window.open("http://www.baidu.com","baidu"+1,"height=450,width=450");
}
function click(){
w.close();
}
</script>
<hr>
<h1>3. 编写登录页面:登录按钮、注册按钮(window.location )跳转注册页面?</h1>
<input type="submit" value="注册" onclick="javascript:
window.location.href='4.html'">
<input type="submit" value="登录" onclick="javascript:
window.location.href='3.html'"/> </body>
</html>

Javascript设置广告和时间表和数组的学习

 <html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>4. 获取当前时间,格式如下:2016年9月20日 12:12:12 星期二 </h1>
<hr/>
<script language="javascript">
var date=new Date();
document.write("当前的时间:"+date+"<br/>");
document.write(date.getFullYear()+"年");
document.write((date.getMonth()+1)+"月");
document.write(date.getDate()+"日&nbsp;&nbsp;&nbsp;&nbsp;");
document.write(date.getHours()+":");
document.write(date.getMinutes()+":");
document.write(date.getSeconds());
document.write("&nbsp;&nbsp;&nbsp;&nbsp;星期"+date.getDay());
</script>
</body>
</html>

Javascript设置广告和时间表和数组的学习

 <html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title></title>
</head>
<body>
<h1>1:Javascript中数组的学习和练习</h1>
<script language="javascript">
document.write("1:创建一个空数组"+"<br/>");
var arr1=new Array();
document.write("var arr1 = new Array()"+"<br/>");
document.write("2:指定数组的长度"+"<br/>");
var arr2=new Array(5);
document.write("var arr2 = new Array(5)"+"<br/>");
document.write("3:创建数组并初始化参数"+"<br/>");
//console.log(arr2.length);
var arr3=new Array(9528,"小别","男");
document.write("var arr3=new Array(9528,小别,男)"+"<br/>");
document.write("4:创建一个数组"+"<br/>");
var arr4=[];
document.write("var arr4 = []"+"<br/>");
document.write("5:使用括号[],并且传入初始值"+"<br/>");
var arr5=[12,23,45,6,8];
document.write("var arr4=[12,23,45,56,6,8]"+"<br/>");
document.write("<hr>");
var arr6=new Array(5);
document.write("arr6数组的长度:"+arr6.length+"<br/>");
document.write("arr6数组的元素:"+arr6+"<br/>");
console.log(arr6);
var arr7=new Array(5,6);
document.write("arr7数组的长度:"+arr7.length+"<br/>");
document.write("arr7数组的元素"+arr7+"<br/>");
var arr8=[11,47,88,525,66,9,4];
document.write("arr8数组的长度:"+arr8.length+"<br/>");
document.write("arr8数组的元素"+arr8+"<br/>");
var arr9=[78,84,51,263,95,62];
document.write("arr9的数组元素:"+arr9+"<br/>");
document.write("arr9[0]="+arr9[0]+"<br/>");
var i=1;
document.write("arr9[1]="+arr9[i]+"<br/>");
document.write("arr9[2]="+arr9[++i]+"<br/>");
var array=[74,54,69];
array[5]=12;
for(var i=0;i<array.length;i++){
document.write("array"+"["+i+"]"+"="+array[i]+",");
}
document.write("<hr>");
document.write("数组元素的添加"+"<br/>");
var arr=new Array;
arr[0]="编号";
arr[1]="姓名";
arr[2]="年龄";
arr[3]="性别";
document.write("数组元素添加:"+arr+"<br/>");
document.write("数组元素的删除:"+"<br/>");
delete arr[3];
document.write("删除后的效果:"+arr+"<br/>");
document.write("<hr>");
document.write("数组的截取"+"<br/>");
var arr=new Array(45,78,9,6,3,2,5,7);
document.write("数组的原始长度:"+arr+"<br/>");
document.write("数组的截取前闭后开:"+arr.slice(1,2)+"<br/>");
document.write("<hr>");
document.write("数组的合并"+"<br/>");
var arr1=[4,7,8,5,2,63];
var arr2=[7,5,2,6,9];
var arr3=arr1.concat(arr2);
document.write("合并后的arr3:"+arr3+"<br/>");
document.write("<hr>");
document.write("数组元素的反转"+"<br/>");
var arr1=[12,45,78,9,6,3,6,4,45];
document.write("数组元素反转前:"+arr1+"<br/>");
arr1.reverse();
document.write("数组元素反转后:"+arr1+"<br/>");
document.write("<hr>");
document.write("数组的任意多数的排序"+"<br/>");
var arr=[45,7,555,336,4,2,1,40];
function sortArray(a,b){
return a-b;
}
document.write("排序前:"+arr+"<br/>");
document.write("排序后:"+arr.sort(sortArray)+"<br/>");
document.write("<hr>");
document.write("数组字符串的学习"+"<br>");
var arr=[11,44,55,66,99,88,77,22,33];
document.write("数组字符串前:"+arr+"<br/>");
document.write("数组字符串化:"+arr.join(" ")+"<br/>");
document.write("数组字符串化:"+arr.join("|")+"<br/>");
</script>
<h1>2:浏览器对象模型的学习和练习</h1>
<script language="javascript">
window.document.write("所有js全局变量,函数,变量均自动成为window对象的成员");
//window.alert("你好哟!!!");
document.write("<hr>");
document.write("window的尺寸"+"<br/>");
var h=window.innerHeight;
var w=window.innerWidth;
document.write("浏览器现在的高:"+h+" 宽:"+w+"<br/>");
//var ieh=window.document.documentElement.clientHeight;
//var iew=window.document.documentElement.clientWidth;
//alert(ieh+""+iew);
//window.open("http://www.baidu.com","baidu","height=300,width=250");
document.write("<hr>");
document.write("可用的屏幕"+"<br/>");
document.write("可用的屏幕的高度:"+screen.availHeight+"<br/>");
document.write("可用的屏幕的宽度:"+screen.availWidth+"<br/>");
document.write("<hr>");
document.write("Window.location对象用于获取当前页面的地址"+"<br/>");
document.write("当前页面的路径:"+window.location.pathname+"<br/>");
//document.write("当前页面的port:"+window.location.port+"<br/>");
</script>
<hr>
<script language="javascript">
var name=prompt("请输入您的尊姓大名.");
document.write(name+"<br/>");
</script>
<input type="button" value="删除" onclick="del()"/>
<script language="javascript">
function del(){
if(confirm("您确认删除嘛??")){
alert("你好狠心!555555");
}else{
alert("你真好!美美哒");
}
}
</script>
</body>
</html>
上一篇:Datagrid,DataList,Repeate等的数据格式设置表达式


下一篇:angular2^ typescript 将 文件和Json数据 合并发送到服务器(1.客户端处理)