


Implementing full-screen floating ads based on javascript_javascript skills
The example in this article is to share with you how to implement full-screen floating ads using javascript for your reference. The specific content is as follows
Main methods of use
Visible area width of web page: document.body.clientWidth;
The height of the visible area of the web page: document.body.clientHeight;
Width of the visible area of the web page: document.body.offsetWidth (including the width of the side lines);
The height of the visible area of the web page: document.body.offsetHeight (including the width of the edge);
setInterval
The setInterval action is used to call functions, methods or objects at certain intervals when playing animation. You can use this action to update variables from the database or update the time display.
The syntax format of the setInterval action is as follows:
setInterval(function,interval[,arg1,arg2,......argn]) setInterval(object,methodName,interval[,arg1,arg2,.....argn])
The first format is the default syntax of the setInterval function in the standard action panel, and the second format is the method used in expert mode actions.
The parameter function is a function name or a reference to an anonymous function.
The object parameter specifies an object derived from the Object object. methodName specifies the method to be called in the object parameter.
Interval specifies the time between two calls to function or methodName, in milliseconds. The following arg1 and so on are optional parameters, used to specify the parameters passed to function or methodName.
The time interval setInterval sets is less than the animation frame rate (such as 10 frames per second, equivalent to 100 milliseconds), and the function is called at a time interval as close as possible to interval. And the updateAfterEvent action must be used to ensure that the screen is refreshed with sufficient frequency. If interval is greater than the animation frame rate, it is only called every time the playhead enters a certain frame to reduce the impact of each screen refresh.
clearInterval
The role of the clearInterval action is to clear the call to the setInterval function
Its syntax format is as follows:
ClearInterval(intervalid);
Advertising mobile effect examples
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>简单JS动画实例 广告移动效果</title> </head> <body> <div id="one" style="background-color:red; position:absolute; left:0; top:0; height:100px; height:100px; "> 移动广告 </div> <script type="text/javascript"> var x=0; //对象X轴位置 var y=0; //对象Y轴位置 var xs = 10; //对象X轴移动速度 var ys = 10; //对象Y轴移动速度 var one = document.getElementById('one'); function move(){ x += xs; y += ys; one.style.left = x; one.style.top = y; if (x > document.body.clientWidth - one.offsetWidth-20 || x<0) { xs = -1*xs; //速度取反 } if (y > document.body.clientHeight - one.offsetHeight-20 || y<0){ ys = -1*ys; } } var obj = setInterval('move()', 100); one.onmouseover = function(){ // clearInterval(obj); } one.onmouseout = function (){ obj = setInterval('move()', 100); } </script> </body> </html>
The above is the entire content of this article, I hope it will be helpful to everyone’s study.

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



Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

JavaScript can be run in PowerPoint, and can be implemented by calling external JavaScript files or embedding HTML files through VBA. 1. To use VBA to call JavaScript files, you need to enable macros and have VBA programming knowledge. 2. Embed HTML files containing JavaScript, which are simple and easy to use but are subject to security restrictions. Advantages include extended functions and flexibility, while disadvantages involve security, compatibility and complexity. In practice, attention should be paid to security, compatibility, performance and user experience.

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.
