20151113

<!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=utf-8" />
<title>无标题文档</title>

<script type="application/javascript">

var a = 'asas'.length;
alert(a);

var b = 'sdal打算fsdl就分手'.length;

alert(b);
alert('字符串的查找='+'abcdef'.indexOf('c'));//字符串的查找索引从零开始

alert('字符串的截取='+'abcdef'.substr(2,2));

alert('字符串的截取='+'abcdef'.substr(2));

alert('字符串的截取1='+'abcdef'.substring(2));

alert('字符串的替换='+'abcdef'.replace('bc','ww'));

var sz = "2015-11-13".split("-");
for(i = 0; i < sz.length; i++)
{
    alert("sz = "+ sz[i]);
    }
    
var dt = new Date(2015,1,5,1,1,1,1);
alert(
dt.getFullYear() + "-" 
+ dt.getMonth() + "-" 
+ dt.getDate() + " " 
+ dt.getHours() + ":" 
+ dt.getMinutes() + ":" 
+ dt.getSeconds() + " " 
+ dt.getDay());

window.alert();
    
    
    
</script>
</head>

<body>

<input type="button" value="打开新窗口" onclick=
"window.open('http://www.baidu.com','百度',
'width=600,height=400,top=50,left=100');"/>


<input type="button" value="关闭当前窗口" onclick=
"window.close()"/>

</body>
</html>
<!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=utf-8" />
<title>无标题文档</title>

<script type="application/javascript">
alert("提示")


function test()
{
    alert("函数里的提示")
    }
test();//函数的调用

function test1(var1,var2)
{
    var a = var1 + var2;
    
    alert(a);
    
    }

function test2(dianj,shul)
{
    var jine = (dianj + shul);
    alert('总价:' + jine);
    return jine;
}

function test3(dianj,shul)
{
    return jne = danj * sul ;
    alert('总价:' + jne);
}

</script>
</head>

<body>

<input type="button" value="按钮" onclick="test1('上午好,','你好!');"/>  

<input type="button" value="按钮2" onclick="test2(5,20);"/>  

<input type="button" value="按钮3" onclick="test1('5','20');"/> 
 
</body>
</html>

原文地址:https://www.cnblogs.com/name-hanlin/p/4963387.html