JavaScript简介

由于本人水平有限,如下有什么技术错误请在后台留言指正,您的一小步指正是我一大步的进步,谢谢!!!
JavaScript一种直译式脚本语言,是一种动态类型、弱类型、基于原型的语言,内置支持类型。它的解释器被称为JavaScript引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在HTML(标准通用标记语言下的一个应用)网页上使用,用来给HTML网页增加动态功能。目前广泛应用于WEB应用开发,是门不错的脚本语言!
在1995年时,由Netscape公司的Brendan Eich,在网景导航者浏览器上首次设计实现而成。因为Netscape与Sun合作,Netscape管理层希望它外观看起来像Java,因此取名为JavaScript。但实际上它的语法风格与Self及Scheme较为接近。为了取得技术优势,微软推出JScript,CEnvi推出ScriptEase,与JavaScript同样可在浏览器上运行。为了统一规格,因为JavaScript兼容于ECMA标准,因此也称为ECMAScript。
它由三大块组成:①,ECMAScript,描述了该语言的语法和基本对象。②,文档对象模型(DOM),描述处理网页内容的方法和接口。③,浏览器对象模型(BOM),描述与浏览器进行交互的方法和接口。
下面的代码是从网上找到的,感觉挺炫。所以现在先拿来刺激刺激自己的内心,我相信自己能设计的效果比他还炫!

<html>
    <head>
    <title>Unkwon</title>
    <style type="text/css">
    html {
    overflow: hidden;
    }
    body {
    position: absolute;
    height: 100%;
    width: 100%;
    margin:0;
    padding:0;
    }
    #screen {
    background:#000;
    position: absolute;
    width: 100%;
    height: 100%;
    }
    #screen span {
    background: #fff;
    font-size: 0;
    overflow: hidden;
    width: 2px;
    height: 2px;
    }
    </style>
    <script type="text/javascript">
    var Follow = function () {
    var $ = function (i) {return document.getElementById(i)},
    addEvent = function (o, e, f) {o.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on'+e, function(){f.call(o)})},
    OBJ = [], sp, rs, N = 0, m;
    var init = function (id, config) {
    this.config = config || {};
    this.obj = $(id);
    sp = this.config.speed || 4;
    rs = this.config.animR || 1;
    m = {x: $(id).offsetWidth * .5, y: $(id).offsetHeight * .5};
    this.setXY();
    this.start();
    }
    init.prototype = {
    setXY : function () {
    var _this = this;
    addEvent(this.obj, 'mousemove', function (e) {
    e = e || window.event;
    m.x = e.clientX;
    m.y = e.clientY;
    })
    },
    start : function () {
    var k = 180 / Math.PI, OO, o, _this = this, fn = this.config.fn;
    OBJ[N++] = OO = new CObj(null, 0, 0);
    for(var i=0;i<360;i+=20){
    var O = OO;
    for(var j=10; j<35; j+=1){
    var x = fn(i, j).x,
    y = fn(i, j).y;
    OBJ[N++] = o = new CObj(O , x, y);
    O = o;
    }
    }
    setInterval(function() {
    for (var i = 0; i < N; i++) OBJ[i].run();
    }, 16);
    }
    }
    var CObj = function (p, cx, cy) {
    var obj = document.createElement("span");
    this.css = obj.style;
    this.css.position = "absolute";
    this.css.left = "-1000px";
    this.css.zIndex = 1000 - N;
    document.getElementById("screen").appendChild(obj);
    this.ddx = 0;
    this.ddy = 0;
    this.PX = 0;
    this.PY = 0;
    this.x = 0;
    this.y = 0;
    this.x0 = 0;
    this.y0 = 0;
    this.cx = cx;
    this.cy = cy;
    this.parent = p;
    }
    CObj.prototype.run = function () {
    if (!this.parent) {
    this.x0 = m.x;
    this.y0 = m.y;
    } else {
    this.x0 = this.parent.x;
    this.y0 = this.parent.y;
    }
    this.x = this.PX += (this.ddx += ((this.x0 - this.PX - this.ddx) + this.cx) / rs) / sp;
    this.y = this.PY += (this.ddy += ((this.y0 - this.PY - this.ddy) + this.cy) / rs) / sp;
    this.css.left = Math.round(this.x) + 'px';
    this.css.top = Math.round(this.y) + 'px';
    }
    return init;
    }();
    </script></head>
    <body>
    <div id="screen"></div>
    <script type="text/javascript">
    new Follow('screen', {speed: 4,
    animR : 2,
    fn : function (i, j) {
    return {
    x : j/4*Math.cos(i),
    y : j/4*Math.sin(i)
    }
    }})
    </script></body>
    </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值