Home Web Front-end JS Tutorial Javascript implementation of pop-up box sample code that cannot be closed

Javascript implementation of pop-up box sample code that cannot be closed

Jul 07, 2017 pm 02:55 PM
javascript js Example

This article shares the example code of javascript to implement a pop-up box that cannot be closed. Interested friends can take a look at it

Everyone has seen a malicious advertisement on a certain web page, but you closed it and it came out again! Why, JS will tell you

HTML

1

2

3

4

5

6

7

8

9

10

<body>

  <h3 class="whiteColor">无法关闭的弹框,打不死的小强!</h3>

  <p id="middleBox">

    <a href="javascript:;" class="close_btn" id="closeBtn"><img src="images/close_icon.png" alt="" class="will_close"></a>

    <ul class="parent_btn">

      <li><a href="/" class="btn_tel"><img src="images/icon_tel.gif" alt=""><span>拨打电话</span></a></li>

      <li><a href="/" class="btn_chat"><img src="images/icon_chat.gif" alt=""><span>快速留言</span></a></li>

    </ul>

  </p>

</body>

Copy after login

CSS

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

*{

  margin: 0;

  padding: 0;

  list-style: none;

  outline: none;

  box-sizing: border-box;

  text-decoration: none;

}

a { -webkit-touch-callout: none; text-decoration: none }

:focus { outline: 0 }

body{

  font-family: Helvetica, STHeiTi, "Microsoft YaHei", sans-serif;

  color: #595757;

  background-color: #fff;

  outline: 0;

  overflow-x: hidden;

  -webkit-tap-highlight-color:rgba(0,0,0,0);

}

img{

  border: none;

}

.whiteColor{

  color: #fff;

  text-align: center;

}

.flex_parent{

  display: -webkit-box;

  display: -moz-box;

  display: -ms-flexbox;

  display: -webkit-flex;

  display: flex;

}

.flex_child{

  -webkit-box-flex: 1;

  -moz-box-flex: 1;

  -webkit-flex: 1;

  -ms-flex: 1;

  flex: 1;

}

/*middle_box*/

body{

  position: relative;

  background-color: #272822;

}

#middleBox{

  width: 260px;

  height: 248px;

  margin: 0 auto;

  background-image: url(../images/irfa_dog.jpg);

  background-repeat: no-repeat;

  background-size: 100% 100%;

  border-radius: 10px;

  /*水平垂直居中*/

  position: fixed;

  left: 50%;

  top: 50%;

  margin-top: -124px;

  -webkit-transform: translateX(-50%);

  -moz-transform: translateX(-50%);

  -o-transform: translateX(-50%);

  -ms-transform: translateX(-50%);

  transform: translateX(-50%);

  z-index: 100;

}

.close_btn{

  display: block;

  overflow: hidden;

  position: absolute;

  top: -10px;

  right: -10px;

}

.will_close{

  width:32px;

}

#middleBox a{

  overflow: hidden;

}

#middleBox a img,#middleBox a span,#middleBox ul li{

  float: left;

}

#middleBox a span{

  font-size: 16px;

  color: #fff;

}

#middleBox ul{

  overflow: hidden;

}

#middleBox ul li{

  width: 130px;

}

#middleBox ul li a{

  line-height: 50px;

  display: block;

  padding-left: 5px;

}

#middleBox ul li a img{

  width:30px;

  margin-right: 2px;

  margin-top: 8px;

  margin-left: 5px;

}

.btn_tel{

  background-color: #F92665;

  border-bottom-left-radius: 10px;

}

.btn_chat{

  background-color: #1EA362;

  border-bottom-right-radius: 10px;

}

.parent_btn{

  position: absolute;

  left: 0;

  bottom: 0;

}

Copy after login

JS

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

/**

 * Created by Administrator on 2016/7/19.

 */

var adv={

  p:null,

  timer:null,

  btn:null,

  init:function(){

    this.btn=document.getElementById("closeBtn");

    this.p=document.getElementById("middleBox");

    this.btn.onclick=this.displayNone;

  },

  displayBlock:function(){

    adv.p.style.display="block";

  },

  displayNone:function(){

    adv.p.style.display="none";

    timer=setTimeout(function(){

      adv.displayBlock();

    },3000);

  }

};

window.onload=function(){

  adv.init();

};

Copy after login

The above is the detailed content of Javascript implementation of pop-up box sample code that cannot be closed. For more information, please follow other related articles on the PHP Chinese website!

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)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
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

Oracle DECODE function detailed explanation and usage examples Oracle DECODE function detailed explanation and usage examples Mar 08, 2024 pm 03:51 PM

The DECODE function in Oracle is a conditional expression that is often used to return different results based on different conditions in query statements. This article will introduce the syntax, usage and sample code of the DECODE function in detail. 1. DECODE function syntax DECODE(expr,search1,result1[,search2,result2,...,default]) expr: the expression or field to be compared. search1,

Go language indentation specifications and examples Go language indentation specifications and examples Mar 22, 2024 pm 09:33 PM

Indentation specifications and examples of Go language Go language is a programming language developed by Google. It is known for its concise and clear syntax, in which indentation specifications play a crucial role in the readability and beauty of the code. effect. This article will introduce the indentation specifications of the Go language and explain in detail through specific code examples. Indentation specifications In the Go language, tabs are used for indentation instead of spaces. Each level of indentation is one tab, usually set to a width of 4 spaces. Such specifications unify the coding style and enable teams to work together to compile

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts Dec 18, 2023 pm 03:39 PM

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

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

The relationship between js and vue The relationship between js and vue Mar 11, 2024 pm 05:21 PM

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

Application and example analysis of PHP dot operator Application and example analysis of PHP dot operator Mar 28, 2024 pm 12:06 PM

Application and example analysis of PHP dot operator In PHP, the dot operator (".") is an operator used to connect two strings. It is very commonly used and very flexible when concatenating strings. By using the dot operator, we can easily concatenate multiple strings to form a new string. The following will introduce the use of PHP dot operators through example analysis. 1. Basic usage First, let’s look at a basic usage example. Suppose there are two variables $str1 and $str2, which store two words respectively.

How to get HTTP status code in JavaScript the easy way How to get HTTP status code in JavaScript the easy way Jan 05, 2024 pm 01:37 PM

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

See all articles