JQ插件第五十一:老式漂浮广告图片

jQuery.piao = {
    "ads": new Object,
    "newFloatAd": function(options) {
        var defaultValue = { img: "", link: "", width: "190px", height: "48px" };
        var opts = $.extend(defaultValue, options || {});
        var ad = document.createElement("span");
        ad.id = "adId";
        ad.innerHTML += "<div  οnclick='guanbu(this)'οnmοuseοver='over()' οnmοuseοut='out(this)'  style='position:absolute; right:3px; top:0px;cursor:pointer;'>×</div>";
        ad.DirV = true;
        ad.DirH = true;
        ad.AutoMove = true;
        ad.style.cursor = 'pointer';
        ad.Image = new Image;
        ad.Seed = Math.random();
        ad.Timer = setInterval("$.piao.float(" + ad.Seed + ")", 50);
        this.ads[ad.Seed] = ad;
        ad.Image.Parent = ad;
        ad.Image.onclick = function() { window.location.href = opts.link; }

        ad.style.position = "absolute";
        ad.style.left = 0;
        ad.style.top = 0;
        ad.Image.src = opts.img;
        ad.Image.onmouseover = function() { this.Parent.AutoMove = false; }
        ad.Image.onmouseout = function() { this.Parent.AutoMove = true; }
        ad.Image.style.width = opts.width;
        ad.Image.style.height = opts.height;
        ad.appendChild(ad.Image);
        document.body.appendChild(ad);
        return ad;
    },
    "float": function(floatId) {
        var ad = this.ads[floatId];
        if (ad.AutoMove) {
            var curLeft = parseInt(ad.style.left);
            var curTop = parseInt(ad.style.top);
            if (ad.offsetWidth + curLeft > document.body.clientWidth + document.body.scrollLeft - 1) {
                curLeft = document.body.scrollLeft + document.body.clientWidth - ad.offsetWidth;
                ad.DirH = false;
            }
            if (ad.offsetHeight + curTop > document.body.clientHeight + document.body.scrollTop - 1) {
                curTop = document.body.scrollTop + document.body.clientHeight - ad.offsetHeight;
                ad.DirV = false;
            }
            if (curLeft < document.body.scrollLeft) {
                curLeft = document.body.scrollLeft;
                ad.DirH = true;
            }
            if (curTop < document.body.scrollTop) {
                curTop = document.body.scrollTop;
                ad.DirV = true;
            }
            ad.style.left = curLeft + (ad.DirH ? 1 : -1) + "px";
            ad.style.top = curTop + (ad.DirV ? 1 : -1) + "px";
        }
    }
}
$.piao.newFloatAd({ img: "/Images/1.jpg", link: "http://www.baidu.com" });


老效果,七八年前首页流行的漂浮广告

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jq select 件是一个 jQuery 件,用于美化 HTML 的 select 元素。它可以将 select 元素转换为带有自定义样式的下拉框,支持搜索、多选等功能,并且使用简单,兼容性好。 以下是 jq select 件的一些特点: 1. 支持搜索:可以在下拉框中搜索选项,快速定位需要的选项。 2. 支持多选:可以选择多个选项,可以设置最大可选数量。 3. 支持自定义样式:可以根据需要自定义下拉框的样式,支持自定义图标、字体等。 4. 兼容性好:支持主流浏览器,包括 Chrome、Firefox、Safari、IE 等。 以下是使用 jq select 件的示例代码: ``` <!-- HTML 代码 --> <select id="mySelect"> <option value="1">选项一</option> <option value="2">选项二</option> <option value="3">选项三</option> <option value="4">选项四</option> <option value="5">选项五</option> </select> <!-- 引入 jQuery 和 jq select 件 --> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://cdn.bootcdn.net/ajax/libs/jquery-selectric/1.13.0/jquery.selectric.min.js"></script> <!-- 初始化 jq select 件 --> <script> $(document).ready(function() { $('#mySelect').selectric(); }); </script> ``` 在上面的代码中,首先在 HTML 中定义了一个 select 元素,然后引入了 jQuery 和 jq select 件的 JS 文件,最后在 document.ready 函数中使用 selectric 方法初始化了 select 元素,即将 select 元素转换为一个带有自定义样式的下拉框。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值