Javascript to disable the warning bar at the top of the IE imitation

Source: Internet
Author: User

Javascript to disable the warning bar at the top of the IE imitation

Similar to the warning toolbar on the top of windows IE, with the close button, the design is still exquisite. You can use your own webpage for display and other aspects. If you need it, you can refer to it.

The function is very practical, and the code is very simple, so there will be little nonsense. We will provide it directly:

?

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

<! 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> similar to the warning bar at the top of IE, you can disable it </title>

<Style type = "text/css">

# Informationbar {

Position: fixed;

Left: 0;

Width: 100%;

Text-indent: 5px;

Padding: 5px 0;

Background-color: lightyellow;

Border-bottom: 1px solid black;

Font: bold 12px Verdana;

}

* Html # informationbar {/* IE6 hack */

Position: absolute;

Width: expression (document. compatMode = "CSS1Compat "? Document.doc umentElement. clientWidth + "px": body. clientWidth + "px ");

}

</Style>

<Script type = "text/javascript">

Function informationbar (){

This. displayfreq = "always"

This. content = '<a href = "javascript: informationbar. close () ">

 

/> </A>'

}

Informationbar. prototype. setContent = function (data ){

This. content = this. content + data

Document. write ('<div id = "informationbar" style = "top:-500px">' + this. content + '</div> ')

}

Informationbar. prototype. animatetoview = function (){

Var barinstance = this

If (parseInt (this. barref. style. top) <0 ){

This. barref. style. top = parseInt (this. barref. style. top) + 5 + "px"

SetTimeout (function () {barinstance. animatetoview ()}, 50)

}

Else {

If (document. all &&! Window. XMLHttpRequest)

This. barref. style. setExpression ("top", 'document. compatMode = "CSS1Compat "? Document.doc umentElement. scrollTop + "px": body. scrollTop + "px "')

Else

This. barref. style. top = 0

}

}

Informationbar. close = function (){

Document. getElementById ("informationbar"). style. display = "none"

If (this. displayfreq = "session ")

Document. cookie = "infobarshown = 1; path = /"

}

Informationbar. prototype. setfrequency = function (type ){

This. displayfreq = type

}

Informationbar. prototype. initialize = function (){

If (this. displayfreq = "session" & document. cookie. indexOf ("infobarshown") =-1 | this. displayfreq = "always "){

This. barref = document. getElementById ("informationbar ")

This. barheight = parseInt (this. barref. offsetHeight)

This. barref. style. top = this. barheight * (-1) + "px"

This. animatetoview ()

}

}

Window. onunload = function (){

This. barref = null

}

</Script>

<Script type = "text/javascript">

<! -- Invocation code -->

Var infobar = new informationbar ()

Infobar. setContent! <A href = "#"> buy sacks </a> <a href = "#"> buy sacks </a> ')

Infobar. initialize ()

</Script>

</Head>

<Body>

</Body>

</Html>

The above is all the content of this article. I hope you will like it.

Note <>: For more exciting tutorials, please pay attention to the help house programming

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.