您的位置:首页 > Web前端 > JavaScript

JavaScript主要对象测试代码

2010-06-16 17:32 387 查看
<html>
<head>
<title>我的第一个 HTML 页面</title>
</head>
<body>
<script>

document.write("Array begin********"+'<br>');
var my_array = new Array();
for (i = 0; i < 2; i++)
{
my_array[i] = i;
document.write(my_array[i]+' ');
}
document.write('<br>'+"Array end********"+'<br>');

document.write('<br>'+"Date begin********"+'<br>');
var myDate=new Date();
document.write(myDate.getDate()+'/n');
var birthday = new Date("July 21, 1983 01:15:00")
document.write('Birthday is '+birthday.getDate());
document.write('<br>'+"Date end********"+'<br>');

document.write('<br>'+"Math begin********"+'<br>');
var pi_value=Math.PI;
var sqrt_value=Math.sqrt(15);
document.write(pi_value);
document.write('<br>'+sqrt_value);
document.write('<br>'+"Math end********"+'<br>');

document.write('<br>'+"RegExp begin********"+'<br>');
var myString="这是第一个正则表达式的例子";
var matchString="一个";
var myregex = new RegExp(matchString);
if(myregex.test(myString)){
document.write('Found string /"'+matchString+'/" in string' +'/"'+myString+'/"');
}
else{
document.write('Not found string /"'+matchString+'/" in string' +'/"'+myString+'/"');
}
document.write('<br>'+"RegExp end********"+'<br>');

document.write('<br>'+"Window begin********"+'<br>');
document.write('This will open a link in another window');
window.open("http://blog.csdn.net/makefish/archive/2010/06/15/5672767.aspx");
document.write('<br>'+"Window end********"+'<br>');

</script>
</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: