当前位置:学会吧培训频道电脑知识学习网页制作Javascript教程JavaScript 浮动广告类» 正文

JavaScript 浮动广告类

[08-08 00:43:18]   来源:http://www.xuehuiba.com  Javascript教程   阅读:8909
概要:/** File: KM.AD.js* Description: KaiMo advertisement Class* Author: Dnawo* Date: 2009-07-22** e.g.** var ad = new KM.AD();* ad.LeftTop = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);* ad.RightTop = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xu
JavaScript 浮动广告类,标签:javascript视频教程,javascript教程下载,http://www.xuehuiba.com

/*
*    File: KM.AD.js
*    Description: KaiMo advertisement Class
*    Author: Dnawo
*    Date: 2009-07-22
*
*    e.g.
*
*    var ad = new KM.AD();
*    ad.LeftTop = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);
*    ad.RightTop = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);
*    ad.LeftMiddle = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);
*    ad.RightMiddle = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);
*    ad.LeftBottom = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);
*    ad.RightBottom = new KM.ADInfo("<a href='#' target='_blank'><img src='http://www.xuehuiba.com/it/200909/ad.gif' border='0' /></a>",137,182);
*    ad.Start();
*/
(function(){
         
    //Namespace
    if(!window.KM)window.KM={};
    if(typeof window.KM != "object")throw new Error("'window.KM' is not an object!");
   
    //Model Class
    KM.ADInfo = function(html,width,height)
    {
        this.Html = html || "";
        this.Width = typeof width == "number" ? width : 0;
        this.Height = typeof height == "number" ? height : 0;
    }
    KM.ADInfo.prototype.toString = function(){
        return "Html:" + this.Html + "rn" +
                "Width:" + this.Width + "rn" +
                "Height:" + this.Height + "rn";
    };
   
    //AD Class
    KM.AD = function()
    {
        /*private members*/
       
        //delay time, (milliseconds)
        var _delay = 50;
        //object initialize
        var _initialize = function(html,width,height){
            var div = document.createElement("div");
            div.id = "km_" + (new Date()).getTime();
            div.style.position = "absolute";
            div.style.backgroundColor = "#FFFFFF";
            div.style.overflow = "hidden";
            div.style.top = "0px";
            div.style.left = "0px";
            div.style.width = width + "px";
            div.style.height = height + "px";
            div.innerHTML = html;
            try{document.getElementsByTagName("body").item(0).appendChild(div)}catch(ex){};
                   
            return div;
        }
        //delete the unit

[1] [2] [3]  下一页


Tag:Javascript教程javascript视频教程,javascript教程下载电脑知识学习 - 网页制作 - Javascript教程
Copyright 学会吧 All Right Reserved.
在线学习社区!--学会吧
1 2 3 4 5 6 7 7 8 9 10 11 12 13