How to enable the translucent prompt layer in JavaScript Animation

Source: Internet
Author: User

How to enable the translucent prompt layer in JavaScript Animation

This article mainly introduces how to enable the translucent prompt layer in JavaScript animation. It involves related techniques related to javascript DOM operations and is very useful. For more information, see

This article describes how to enable the translucent prompt layer in JavaScript animation. Share it with you for your reference. The details are as follows:

?

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

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN"

Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

<Html xmlns = "http://www.w3.org/1999/xhtml">

<Head>

<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>

<Title> DOM translucent prompt layer </title>

<Style type = "text/css">

Body, span, div, td {font-size: 12px; line-height: 1.5em; color: # 849BCA ;}

# BodyL {

Float: left;

Width: 84px;

Margin-right: 2px;

}

A. od {

Width: 80px;

Height: 25px;

Line-height: 25px;

Text-align: center;

Font-weight: bold;

Border: 2px solid # 849BCA;

Display: block;

Color: #547BC9;

Float: left;

Text-decoration: none;

Margin-top: 2px;

}

A. od: link {

Background: # EEF1F8;

}

A. od: visited {

Background: # EEF1F8;

}

A. od: hover {

Background: # EEE;

}

A. od: active {

Background: # EEE;

}

# Fd {

Width: 500px;

Height: 200px;

Background: # EDF1F8;

Border: 2px solid # 849BCA;

Margin-top: 2px;

Margin-left: 2px;

Float: left;

Overflow: hidden;

Position: absolute;

Left: 0px;

Top: 0px;

Cursor: move;

Float: left;

}

. Content {

Padding: 10px;

}

</Style>

</Head>

<Body>

<Div id = "bodyL">

<A href = "#" class = "od" onclick = "show ('fd '); return false;">

[Open layer]

</A>

<A href = "#" class = "od" onclick = "closeed ('fd '); return false;">

[Close layer]

</A>

</Div>

<Div id = "fd" style = "display: none; filter: alpha (opacity = 100); opacity: 1;">

<Div class = "content"> mobile layer </div>

</Div>

<Script type = "text/javascript">

Var prox;

Var proy;

Var proxc;

Var proyc;

Function show (id) {/* -- open --*/

ClearInterval (prox );

ClearInterval (proy );

ClearInterval (proxc );

ClearInterval (proyc );

Var o = document. getElementById (id );

O. style. display = "block ";

O. style. width = "1px ";

O. style. height = "1px ";

Prox = setInterval (function () {openx (o, 500)}, 10 );

}

Function openx (o, x) {/* -- open x --*/

Var cx = parseInt (o. style. width );

If (cx <x)

{

O. style. width = (cx + Math. ceil (x-cx)/5) + "px ";

}

Else

{

ClearInterval (prox );

Proy = setInterval (function () {openy (o, 200)}, 10 );

}

}

Function openy (o, y) {/* -- open y --*/

Var cy = parseInt (o. style. height );

If (cy <y)

{

O. style. height = (cy + Math. ceil (y-cy)/5) + "px ";

}

Else

{

ClearInterval (proy );

}

}

Function closeed (id) {/* -- disable --*/

ClearInterval (prox );

ClearInterval (proy );

ClearInterval (proxc );

ClearInterval (proyc );

Var o = document. getElementById (id );

If (o. style. display = "block ")

{

Proyc = setInterval (function () {closey (o)}, 10 );

}

}

Function closey (o) {/* -- open y --*/

Var cy = parseInt (o. style. height );

If (cy> 0)

{

O. style. height = (cy-Math. ceil (cy/5) + "px ";

}

Else

{

ClearInterval (proyc );

Proxc = setInterval (function () {closex (o)}, 10 );

}

}

Function closex (o) {/* -- open x --*/

Var cx = parseInt (o. style. width );

If (cx> 0)

{

O. style. width = (cx-Math. ceil (cx/5) + "px ";

}

Else

{

ClearInterval (proxc );

O. style. display = "none ";

}

}

/* Drag the mouse */

Var od = document. getElementById ("fd ");

Var dx, dy, mx, my, mouseD;

Var odrag;

Var isIE = document. all? True: false;

Document. onmousedown = function (e ){

Var e = e? E: event;

If (e. button = (document. all? 1: 0 ))

{

MouseD = true;

}

}

Document. onmouseup = function (){

MouseD = false;

Odrag = "";

If (isIE)

{

Od. releaseCapture ();

Od. filters. alpha. opacity = 100;

}

Else

{

Window. releaseEvents (od. MOUSEMOVE );

Od. style. opacity = 1;

}

}

// Function readyMove (e ){

Od. onmousedown = function (e ){

Odrag = this;

Var e = e? E: event;

If (e. button = (document. all? 1: 0 ))

{

Mx = e. clientX;

My = e. clientY;

Od. style. left = od. offsetLeft + "px ";

Od. style. top = od. offsetTop + "px ";

If (isIE)

{

Od. setCapture ();

Od. filters. alpha. opacity = 50;

}

Else

{

Window. captureEvents (Event. MOUSEMOVE );

Od. style. opacity = 0.5;

}

// Alert (mx );

// Alert (my );

}

}

Document. onmousemove = function (e ){

Var e = e? E: event;

// Alert (mrx );

// Alert (e. button );

If (mouseD = true & odrag)

{

Var mrx = e. clientX-mx;

Var mry = e. clientY-my;

Od. style. left = parseInt (od. style. left) + mrx + "px ";

Od. style. top = parseInt (od. style. top) + mry + "px ";

Mx = e. clientX;

My = e. clientY;

}

}

</Script> <br/>

<Div> http://www.jb51.net/</div>

</Body>

</Html>

I hope this article will help you design javascript programs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.