Floating window effect in the lower right corner of a webpage that cannot be blocked by javascript

Source: Internet
Author: User
Tip: you can modify some code before running

<!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><title></title><meta http-equiv="content-type" content="text/html;charset=gb2312"><!--把下面代码加到<head>与</head>之间--><style type="text/css"># Msg_win {border: 1px solid # A67901; background: # EAEAEA; width: 240px; position: absolute; right: 0; font-size: 12px; font-family: Arial; margin: 0px; display: none; overflow: hidden; z-index: 99;} # msg_win. icos {position: absolute; top: 2px; * top: 0px; right: 2px; z-index: 9 ;}. icos a {float: left; color: #833B02; margin: 1px; text-align: center; font-weight: bold; width: 14px; height: 22px; line-height: 22px; padding: 1px; text-decoration: none; font-family: webdings ;}. icos a: hover {color: # fff ;}# msg_title {background: # FECD00; border-bottom: 1px solid # A67901; border-top: 1px solid # FFF; border-left: 1px solid # FFF; color: #000; height: 25px; line-height: 25px; text-indent: 5px ;}# msg_content {margin: 5px; margin-right: 0; width: 230px; height: 126px; overflow: hidden ;}</style></head><body><!--把下面代码加到<body>与</body>之间--><p ></p><div id="msg_win" > <div class="icos">_ ×</div> <div id="msg_title">Www.111cn.net</div> <div id="msg_content">Chinese webmaster sky, webmaster Site Park</div></div><script language="javascript">Var Message = {set: function () {// minimize and restore status switch var set = this. minbtn. status = 1? [0, 1, 'block', this. char [0], 'minimization ']: [1, 0, 'none', this. char [1], 'restore']; this. minbtn. status = set [0]; this. win. style. borderBottomWidth = set [1]; this. content. style. display = set [2]; this. minbtn. innerHTML = set [3] this. minbtn. title = set [4]; this. win. style. top = this. getY (). top ;}, close: function () {// close this. win. style. display = 'none'; window. onscroll = null ;}, setOpacity: function (x) {// sets the transparency var v = x> = 100? '': 'Alpha (opacity = '+ x +') '; this. win. style. visibility = x <= 0? 'Did': 'visible '; // IE has a bugthis where the absolute or relative content does not change with the parent transparency. win. style. filter = v; this. win. style. opacity = x/100;}, show: function () {// gradually display clearInterval (this. timer2); var me = this, fx = this. fx (0,100, 0.1), t = 0; this. timer2 = setInterval (function () {t = fx (); me. setOpacity (t [0]); if (t [1] = 0) {clearInterval (me. timer2) }}, 10) ;}, fx: function (a, B, c) {// buffer calculation var cMath = Math [(a-B)> 0? "Floor": "ceil"], c = c | 0.1; return function () {return [a + = cMath (B-a) * c ), a-B] }}, getY: function () {// calculates the moving coordinate var d = document, B = document. body, e = document.doc umentElement; var s = Math. max (B. scrollTop, e. scrollTop); var h =/BackCompat/I. test (document. compatMode )? B. clientHeight: e. clientHeight; var h2 = this. win. offsetHeight; return {foot: s + h + h2 + 2 + 'px ', top: s + h-h2-2 + 'px'}, moveTo: function (y) {// Move the animation clearInterval (this. timer); var me = this, a = parseInt (this. win. style. top) | 0; var fx = this. fx (a, parseInt (y); var t = 0; this. timer = setInterval (function () {t = fx (); me. win. style. top = t [0] + 'px '; if (t [1] = 0) {clearInterval (me. timer); me. bind () ;}}, 10 ); }, Bind: function () {// bind the window scroll bar and the size change event var me = this, st, rt; window. onscroll = function () {clearTimeout (st); clearTimeout (me. timer2); me. setOpacity (0); st = setTimeout (function () {me. win. style. top = me. getY (). top; me. show () ;}, 600) ;}; window. onresize = function () {clearTimeout (rt); rt = setTimeout (function () {me. win. style. top = me. getY (). top}, 100) ;}}, init: function () {// create HTMLfunction $ (id) {return document. getE LementById (id)}; this. win = $ ('MSG _ win'); var set = {minbtn: 'MSG _ min', closebtn: 'MSG _ close', title: 'MSG _ title ', content: 'MSG _ content'}; for (var Id in set) {this [Id] =$ (set [Id])}; var me = this; this. minbtn. onclick = function () {me. set (); this. blur ()}; this. closebtn. onclick = function () {me. close ()}; this. char = navigator. userAgent. toLowerCase (). indexOf ('Firefox ') + 1? ['_', ':', '×']: ['0', '2', 'R']; // FF does not support the webdings font this. minbtn. innerHTML = this. char [0]; this. closebtn. innerHTML = this. char [2]; setTimeout (function () {// initialize the first position me. win. style. display = 'block'; me. win. style. top = me. getY (). foot; me. moveTo (me. getY (). top) ;}, 0); return this ;}}; Message. init ();</script></body></html>
Tip: you can modify some code before running

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.