• JavaScript 字符串和日期内容整理


    <!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 quanj = '全局变量';
    
    alert('提示');
    
    
    test();
    function test()
    {
        jub = '局部变量';
        
        alert('函数里的提示' + quanj + ' ' + jub);
    }
    
    function test1(var1, var2)
    {
        try{
        var a = var1 + var2 + jub;
        }
        catch(ex)
        {
            alert(ex.message)
        }
        alert(a);
    
    }
    
    function test2(danj, shul)
    {
        return danj * shul;
    }
    
    var b = test2(5,20);
    
    alert('金额 = ' + b);
    
    
    
    </script>
    </head>
    
    <body>
    
    <input type="button" value="按钮" onclick="test1(1,2);"/>
    </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">
    
    var b = 'zxczxc的长度'.length;
    
    alert('字符串长度' + b);
    
    alert('字符串的查找 = ' + 'abcdef'.indexOf('g'));
    
    alert('字符串的查找 = ' + 'abcdedf'.lastIndexOf('d'));
    
    alert('字符串的截取substr = ' + 'abcdedf'.substr(2,3));
    
    alert('字符串的截取substring = ' + 'abcdedf'.substring(2,3));
    
    alert('字符串的替换 = ' + 'abcdedf'.replace('de','00'));
    
    var sz = '2015-11-13'.split('-');
    
    for(i = 0; i < sz.length; i++)
    {
        alert('sz = ' + sz[i]);
    }
    
    var dt = new Date(2015,0,1,1,1,15);
    
    alert(dt.getFullYear() + '-' + dt.getMonth() + '-' + dt.getDate() + '-' + dt.getHours() + '-' + dt.getMinutes() + '-' + dt.getSeconds() + '-' + dt.getDay())
    
    alert(dt);
    </script>
    </head>
    
    <body>
    
    <input type="button" value="打开新窗口" onclick="window.open('http://www.facebook.com','脸谱','width=600,height=400,top=50,left=100,scrollbars=yes,resizeable=yes,toolbar=yes,menubar=yes,location=yes');" />
    
    <input type="button" value="关闭窗口" onclick="window.close();"/>
    </body>
    </html>
  • 相关阅读:
    interface——关于虚函数的内存分配
    [asp.net]网页与服务器的交互模型
    C#下把txt文件数据读进sql server中存储所遇到的乱码问题
    安装window 7 续 ~~~
    ASP.NET中对SQLITE数据库进行插入操作后返回自增的ID
    非IE浏览器下让界面变灰色
    ASPNET目录权限控制
    自己封装的Access数据库的操作类(AccessHelper)
    用WIN7发现的问题(AppHangB1)
    [原创视频]牛腩新闻发布系统(续)
  • 原文地址:https://www.cnblogs.com/shadowduke/p/4963616.html
Copyright © 2020-2023  润新知