1
function getPosition()
{
2
var top = document.body.scrollTop;
3
var left = document.body.scrollLeft;
4
var height = document.body.clientHeight;
5
var width = document.body.clientWidth;
6
return
{top:top,left:left,height:height,width:width};
7
}
8
9
function showDiv()
{
10
var width = 50; //弹出框的宽度
11
var height = 200; //弹出框的高度
12
13
var leftDiv = document.getElementById("leftDiv");
14
leftDiv.style.display = "block";
15
leftDiv.style.position = "absolute";
16
leftDiv.style.zindex = "999";
17
leftDiv.style.width = width + "px";
18
leftDiv.style.height = height + "px";
19
var Position = getPosition();
20
leftadd = (Position.width-width)/2;
21
topadd = (Position.height-height)/2;
22
leftDiv.style.top = (Position.top + 10) + "px";
23
leftDiv.style.left = 20 + "px";
24
25
//右边的 层
26
var rightDiv = document.getElementById("rightDiv");
27
rightDiv.style.display = "block";
28
rightDiv.style.position = "absolute";
29
rightDiv.style.zindex = "999";
30
rightDiv.style.width = width + "px";
31
rightDiv.style.height = height + "px";
32
var Position = getPosition();
33
leftadd = (Position.width-width)/2;
34
topadd = (Position.height-height)/2;
35
rightDiv.style.top = (Position.top + 10) + "px";
36
rightDiv.style.left = (Position.width-100) + "px";
37
38
window.onscroll = function ()
{
39
var Position = getPosition();
40
leftDiv.style.top = (Position.top + 10) +"px";
41
leftDiv.style.left = 20+"px";
42
//alert(Position.top);
43
rightDiv.style.top = (Position.top + 10) +"px";
44
rightDiv.style.left = (Position.width-100) +"px";
45
};
46
47
}
48



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
