Home Web Front-end JS Tutorial JS realizes click login pop-up window and background color gradient animation effect_javascript skills

JS realizes click login pop-up window and background color gradient animation effect_javascript skills

May 16, 2016 pm 03:08 PM
js pop up Gradient animation background color

The example in this article describes the JS implementation of clicking on the login pop-up window and the background color gradient animation effect. Share it with everyone for your reference, the details are as follows:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<STYLE>
  #login{
   position: relative;
   display: none;
     top: 20px;
     left: 30px;
     background-color: #ffffff;
     text-align: center;
     border: solid 1px;
     padding: 10px;
     z-index: 1;
  }
body {
background-color: #0099CC;
}
.STYLE1 {color: #FFFF00}
</STYLE>
<script type="text/javascript">
var W = screen.width;//取得屏幕分辨率宽度
var H = screen.height;//取得屏幕分辨率高度
function M(id){
  return document.getElementById(id);//用M()方法代替document.getElementByIdx_x(id)
}
function MC(t){
  return document.createElement(t);//用MC()方法代替document.createElement_x(t)
};
//判断浏览器是否为IE
function isIE(){
   return (document.all && window.ActiveXObject && !window.opera) &#63; true : false;
}
//取得页面的高宽
function getBodySize(){
  var bodySize = [];
  with(document.documentElement) {
  bodySize[0] = (scrollWidth>clientWidth)&#63;scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度,取得滚动条的宽度,否则取页面宽度
  bodySize[1] = (scrollHeight>clientHeight)&#63;scrollHeight:clientHeight;//如果滚动条的高度大于页面的高度,取得滚动条的高度,否则取高度
  }
  return bodySize;
}
//创建遮盖层
function popCoverDiv(){
  if (M("cover_div")) {
  //如果存在遮盖层,则让其显示
  M("cover_div").style.display = 'block';
  } else {
  //否则创建遮盖层
  var coverDiv = MC('div');
  document.body.appendChild(coverDiv);
  coverDiv.id = 'cover_div';
  with(coverDiv.style) {
   position = 'absolute';
   background = '#CCCCCC';
   left = '0px';
   top = '0px';
   var bodySize = getBodySize();
   width = bodySize[0] + 'px'
   height = bodySize[1] + 'px';
   zIndex = 0;
   if (isIE()) {
   filter = "Alpha(Opacity=60)";//IE逆境
   } else {
   opacity = 0.6;
   }
  }
  }
}
//让登陆层显示为块
function showLogin()
{
  var login=M("login");
  login.style.display = "block";
}
//设置DIV层的样式
function change(){
   var login = M("login");
   login.style.position = "absolute";
   login.style.border = "1px solid #CCCCCC";
   login.style.background ="#F6F6F6";
   var i=0;
   var bodySize = getBodySize();
   login.style.left = (bodySize[0]-i*i*4)/2+"px";
   login.style.top = (bodySize[1]/2-100-i*i)+"px";
   login.style.width =   i*i*4 + "px";
   login.style.height = i*i*1.5 + "px";
   popChange(i);
}
//让DIV层大小循环增大
function popChange(i){
   var login = M("login");
   var bodySize = getBodySize();
   login.style.left = (bodySize[0]-i*i*4)/2+"px";
   login.style.top = (bodySize[1]/2-100-i*i)+"px";
   login.style.width =   i*i*4 + "px";
   login.style.height = i*i*1.5+ "px";
   if(i<=10){
      i++;
      setTimeout("popChange("+i+")",10);//设置超时10毫秒
   }
}
//打开DIV层
function open()
{
    change();
    showLogin();
    popCoverDiv()
    void(0);//不进行任何操作,如:<a href="#">aaa</a>
}
//关闭DIV层
function close(){
     M('login').style.display = 'none';
     M("cover_div").style.display = 'none';
    void(0);
}
</script>
</head>
<body>
<br>
<br>
<div align="center"><a href="javascript:open();" class="STYLE1">登陆</a></div>
<div id="login">
<span>用户登陆</span>
  <div id="panel">
  <lable>用户名: </lable><input type="text" size="20" />
  <lable>密码: </lable><input type="password" size="20">
  <input type="checkbox" /><lable>登陆</lable>
  </div>
  <input type="button" value="提交" />
  <a href="javascript:close();">关闭</a>
</div>
</body>
</html>

Copy after login

Readers who are interested in more JavaScript-related content can check out the special topics on this site: "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation special effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques" and "JavaScript Mathematics Summary of operation usage

I hope this article will be helpful to everyone in JavaScript programming.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to change the background color of Google Chrome? How to set the background color of Google Chrome How to change the background color of Google Chrome? How to set the background color of Google Chrome Mar 13, 2024 pm 01:40 PM

The background of Google Chrome is the default, so how do we set it up if we want to change it? Google Chrome has the function of modifying the background color, but many novice friends don’t know how to modify it. It is actually very simple. Below is the step-by-step method of modifying the background color of Google Chrome. If you are interested, let’s take a look. Modification method: 1. First open Google Chrome and click on the three dots in the upper right corner. 2. Then a drop-down box appears, click Settings. 3. Then click Customize your Chrome profile. 4. Finally, select your favorite color, and the browser background will automatically change color.

How to use JS and Baidu Maps to implement map pan function How to use JS and Baidu Maps to implement map pan function Nov 21, 2023 am 10:00 AM

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

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

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 create a stock candlestick chart using PHP and JS How to create a stock candlestick chart using PHP and JS Dec 17, 2023 am 08:08 AM

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

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Dec 17, 2023 pm 06:55 PM

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

Microsoft Edge tests a new feature to tidy up its experience on Windows 11 Microsoft Edge tests a new feature to tidy up its experience on Windows 11 Nov 07, 2023 pm 11:13 PM

Microsoft Edge with Fluent Design menu on Windows 11 Microsoft is adding a new feature... to tidy up one of Edge's controversial features - the sidebar, which can be docked to the right side of Windows 11 and Windows 10. Microsoft EdgeCanary is testing a new feature or popup that automatically detects unused items in the sidebar. Microsoft is adding a sidebar to Edge in November 2022, promising that the feature will improve your productivity on Windows 10, especially Wind, which Copilot doesn't come with.

How to use JS and Baidu Map to implement map click event processing function How to use JS and Baidu Map to implement map click event processing function Nov 21, 2023 am 11:11 AM

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 map heat map function How to use JS and Baidu Maps to implement map heat map function Nov 21, 2023 am 09:33 AM

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

See all articles