当前位置:首页>>特效代码>>内容详情

漂浮广告代码

2023年09月28日
Tags:飘窗漂浮广告
<!-- 飘窗-->
                <div id="FlAD" style="position: absolute; z-index: 999; left: 100px; top: 100px;">
                    <p style="text-align:right; color:#000000;font-size:12px;cursor:pointer;" onclick="img.style.visibility = 'hidden'">关闭</p>
                    <a href="" id="sca" target="_blank"><img src="" style="background-color: rgb(68, 68, 68); width: 400px;height: 200px;border: none;" id="scimg"></a>
                </div>
                    <script type="text/javascript">
                        var img = document.getElementById('FlAD');
                        var xPos = 0;
                        var yPos = 0;
                        var step = 1;
                        var delay = 30;
                        var height = 0;
                        var Hoffset = 0;
                        var Woffset = 0;
                        var yon = 0;
                        var xon = 0;
                        var pause = true;
                        var interval;
                        img.style.top = yPos;
                        function changePos() {
                            width = document.documentElement.clientWidth || document.body.clientWidth;
                            height = document.documentElement.clientHeight || document.body.clientHeight;
                            scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
                            scrollTop = document.documentElement.scrollLeft || document.body.scrollTop;
                            Hoffset = img.offsetHeight;
                            Woffset = img.offsetWidth;
                            img.style.left = xPos + scrollLeft +'px';
                            img.style.top = yPos + scrollTop +'px';
                            if (yon) {
                                yPos = yPos + step;
                            } else {
                                yPos = yPos - step;
                            }
                            if (yPos < 0) {
                                yon = 1;
                                yPos = 0;
                            }
                            if (yPos >= (height - Hoffset)) {
                                yon = 0;
                                yPos = (height - Hoffset);
                            }
                            if (xon) {
                                xPos = xPos + step;
                            } else {
                                xPos = xPos - step;
                            }
                            if (xPos < 0) {
                                xon = 1;
                                xPos = 0;
                            }
                            if (xPos >= (width - Woffset)) {
                                xon = 0;
                                xPos = (width - Woffset);
                            }
                        }
                        function start() {
                            img.visibility = "visible";
                            interval = setInterval('changePos()', delay);
                        }
                        start();
                    </script>
<!-- 飘窗-->
打开微信,点击底部的“发现”,使用“扫一扫”即可将网页分享至朋友圈。
上一条信息:jQuery全屏滚动插件DD Full Screen Slider
下一条信息:扁平html5音乐播放器代码