


Specific examples of JS random floating advertising code_javascript skills
var xPos=0,yPos=0;//x, y-axis coordinates
var xon= 0;//The picture moves in the x-axis direction
var yon=0;//The picture moves in the y-axis direction
var step=1; //Moving distance
var img=document.getElementByIdx_x("float ");//Picture layer
function floatP()
{
var width=document.body.clientWidth;//Browser width
var height=document.body .clientHeight;//Browser height
var Hoffset=img.offsetHeight;//Image height
var Woffset=img.offsetWidth;//Image width
img.style.left=xPos document .body.scrollLeft;//The distance between the image and the left side of the browser
img.style.top=yPos document.body.scrollTop;//The distance between the image and the top of the browser
if(yon==0 ){
yPos=yPos step;//The picture moves up and down in the y-axis direction
}else{
yPos=yPos-step;
}
if(yPos<0){// Float to the top and move down along the y-axis
yon=0;
yPos=0;
}
if(yPos>=(height-Hoffset)){//Float to the low end, Move upward along the y-axis
yon=1;
yPos=(height-Hoffset);
}
if(xon==0){//x-axis moves right
xPos=xPos step;
}else{
xPos=xPos-step;//The x-axis moves left
}
if(xPos<0){//Float to When moving to the left, move right along the x-axis
xon=0;
Move left along the x-axis
xon=1;
xPos=(width-Woffset);
}
setTimeout("floatP()",30); // Timing call.
}
window.onload=floatP();
<script><br>var x = 50, y = 60 //The initial position of the floating layer corresponds to the initial X coordinate and Y coordinate of the layer respectively <br>var xin = true, yin = true //Determine whether the X coordinate and Y coordinate of the layer are within the control range. If xin is true, the layer moves to the right, otherwise to the left; if yin is true, the layer moves downward, otherwise upward <br>var step = 1 //Layer The step length of movement. The larger the value, the faster the movement speed. <br>var delay = 10 //The time interval for layer movement, in milliseconds. The smaller the value, the faster the movement speed. <br>var obj=document.getElementByIdx_x("float ") //Capture the layer with id ad as a floating target<br>function floatAD() {<br>var L=T=0 //The left boundary (L) and upper boundary (T) coordinates of the layer movement range<br>var R= document.body.clientWidth-obj.offsetWidth //The right boundary of the layer movement<br>var B = document.body.clientHeight-obj.offsetHeight //The lower boundary of the layer movement<br>obj.style.left = x document.body.scrollLeft //Update the X coordinate of the layer to realize movement in the Within the visible range <br>obj.style.top = y document.body.scrollTop //Update the Y coordinate of the layer to achieve movement in the Y-axis direction; document.body.scrollTop is the downward distance of the scroll bar in the document area , to ensure that the layer is still within the visible range when the scroll bar is pulled down<br>x = x step*(xin?1:-1) //Determine the movement direction of the layer on the X axis by judging the range of the layer<br>if (x < L) { xin = true; x = L} //Handling when the layer exceeds the left boundary<BR>if (x > R){ xin = false; x = R} //When the layer exceeds the right boundary Processing<br>y = y step*(yin?1:-1) //Determine the movement direction of the layer on the Y axis by judging the range of the layer<br>if (y < T) { yin = true; y = T } //Handling when the layer exceeds the upper boundary<BR>if (y > B) { yin = false; y = B } //Handling when the layer exceeds the lower boundary<br>}<br>var itl= setInterval("floatAD()", delay) //Execute the floatAD function every delay seconds<br>obj.onmouseover=function(){clearInterval(itl)} //The layer clears the above interval event when the mouse moves up, to achieve The effect of stopping the movement of the layer when the mouse moves up<br>obj.onmouseout=function(){itl=setInterval("floatAD()", delay)} //The layer starts interval events when the mouse moves away to realize the layer's movement when the mouse moves up The effect of continuing to move when the mouse is removed <br></script>
Note:
Insert Flash and floating ads into the web page, you will find that the floating ads float to the Flash The time will be below,
How do we solve this problem?
The rest is very simple
Just add the following statement to the flash code position
Example:
If the following is the code where the flash is located:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

How to use JS and Baidu Map to implement map pan function Baidu Map is a widely used map service platform, which is often used in web development to display geographical information, positioning and other functions. This article will introduce how to use JS and Baidu Map API to implement the map pan function, and provide specific code examples. 1. Preparation Before using Baidu Map API, you first need to apply for a developer account on Baidu Map Open Platform (http://lbsyun.baidu.com/) and create an application. Creation completed

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

How to use PHP and JS to create a stock candle chart. A stock candle chart is a common technical analysis graphic in the stock market. It helps investors understand stocks more intuitively by drawing data such as the opening price, closing price, highest price and lowest price of the stock. price fluctuations. This article will teach you how to create stock candle charts using PHP and JS, with specific code examples. 1. Preparation Before starting, we need to prepare the following environment: 1. A server running PHP 2. A browser that supports HTML5 and Canvas 3

Overview of how to use JS and Baidu Maps to implement map click event processing: In web development, it is often necessary to use map functions to display geographical location and geographical information. Click event processing on the map is a commonly used and important part of the map function. This article will introduce how to use JS and Baidu Map API to implement the click event processing function of the map, and give specific code examples. Steps: Import the API file of Baidu Map. First, import the file of Baidu Map API in the HTML file. This can be achieved through the following code:

How to use JS and Baidu Maps to implement the map heat map function Introduction: With the rapid development of the Internet and mobile devices, maps have become a common application scenario. As a visual display method, heat maps can help us understand the distribution of data more intuitively. This article will introduce how to use JS and Baidu Map API to implement the map heat map function, and provide specific code examples. Preparation work: Before starting, you need to prepare the following items: a Baidu developer account, create an application, and obtain the corresponding AP

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

The difference between random and pseudo-random is predictability, reproducibility, uniformity and security. Detailed introduction: 1. Predictability. Random numbers cannot be predicted. Even if the past results are known, future results cannot be accurately predicted. Pseudo-random numbers can be predicted because they are generated by algorithms. As long as you know the algorithm and seed, you can regenerate the same sequence or sequence; 2. Reproducibility, random numbers are not reproducible, and the results generated each time are independent, while pseudo-random numbers are reproducible. Yes, just use the same algorithm and seeds etc.
