JavaScript to generate bubbles by moving the mouse over

Source: Internet
Author: User

JavaScript to generate bubbles by moving the mouse over

This example describes how to generate a bubble by swiping the mouse over JavaScript. Share it with you for your reference. The specific implementation method is 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

<HTML>

<HEAD>

<Title> Generate bubbles around the mouse on the webpage </title>

</HEAD>

<BODY bgColor = #000000 scroll = no onload = zyva ()>

<Div id = aqua style = "position: absolute; left = 0; top = 0;"> </div>

<SCRIPT>

Object = new Array ()

Var xm, ym

Function CObj (N, obj ){

Aqua. insertAdjacentHTML ("AfterBegin", " ")

This. img = aqua. firstChild. style

Mr = Math. random ()

This. v = 6 * mr + 4

This. s =. 5 * mr

This. p =. 1 + mr

This. w = 0

This. k = 0

This. x = xm

This. y = N

This. ChteuMeulEu = function ChteuMeulEu (){

With (this ){

With (img ){

Left = (x + = 0.5 * v * Math. sin (k + = s)-w * 0.5

Top = y-= v

Width = Math. min (w + = p, 100)

}

If (y <-w ){

W = 8

Y = ym

X = xm

}

}

}

}

Function gradient (R, G, B, m ){

For (I = 0; I <25; I ++ ){

C = 255-10 * I

C = "\" RGB ("+ Math. round (c * R/255) + "," + Math. round (c * G/255) + "," + Math. round (c * B/255) + ")\""

Code = "<span style = 'position: absolute; font-size: 1pt; left = 0; width = 120%; height =" + (m) + ". 2%; top = "+ (I * m)

+ "%; Background =" + C + "; z-Index:-1000 '> </span>"

Document. body. insertAdjacentHTML ("beforeEnd", code)

}

}

Function zyva (){

Xm = document. body. offsetWidth * 0.5

Ym = document. body. offsetHeight

Document. onmousemove = function (){

Xm = window. event. clientX

Ym = window. event. clientY

}

For (I = 0; I <60; I ++) object [I] = new CObj (I, B)

SetInterval ("for (I in object) object [I]. ChteuMeulEu ()", 16)

Gradient (41,93, 214,2)

}

</SCRIPT>

</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.