Webページの右下にあるポップアップフォームの実装コード

6154 ワード

 
  









codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="210" height="160">



pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="210" height="160">



<br>var Message = { <br>set: function () {// <br>var set = this.minbtn.status == 1 ? [0, 1, 'block', this.char[0], ' '] : [1, 0, 'none', this.char[1], ' ']; <br>this.minbtn.status = set[0]; <br>this.win.style.borderBottomWidth = set[1]; <br>this.content.style.display = set[2]; <br>this.minbtn.innerHTML = set[3] <br>this.minbtn.title = set[4]; <br>this.win.style.top = this.getY().top; <br>}, <br>close: function () {// <br>this.win.style.display = 'none'; <br>document.all.xhs1.stop(); <br>window.onscroll = null; <br>}, <br>setOpacity: function (x) {// <br>var v = x >= 100 ? '' : 'Alpha(opacity=' + x + ')'; <br>this.win.style.visibility = x <= 0 ? 'hidden' : 'visible'; //IE bug <br>this.win.style.filter = v; <br>this.win.style.opacity = x / 100; <br>}, <br>show: function () {// <br>clearInterval(this.timer2); <br>var me = this, fx = this.fx(0, 100, 0.1), t = 0; <br>this.timer2 = setInterval(function () { <br>t = fx(); <br>me.setOpacity(t[0]); <br>if (t[1] == 0) { clearInterval(me.timer2) } <br>}, 6); //10 to 6 <br>}, <br>fx: function (a, b, c) {// <br>var cMath = Math[(a - b) > 0 ? "floor" : "ceil"], c = c || 0.1; <br>return function () { return [a += cMath((b - a) * c), a - b] } <br>}, <br>getY: function () {// <br>var d = document, b = document.body, e = document.documentElement; <br>var s = Math.max(b.scrollTop, e.scrollTop); <br>var h = /BackCompat/i.test(document.compatMode) ? b.clientHeight : e.clientHeight; <br>var h2 = this.win.offsetHeight; <br>return { foot: s + h + h2 + 2 + 'px', top: s + h - h2 - 2 + 'px' } <br>}, <br>moveTo: function (y) {// <br>clearInterval(this.timer); <br>var me = this, a = parseInt(this.win.style.top) || 0; <br>var fx = this.fx(a, parseInt(y)); <br>var t = 0; <br>this.timer = setInterval(function () { <br>t = fx(); <br>me.win.style.top = t[0] + 'px'; <br>if (t[1] == 0) { <br>clearInterval(me.timer); <br>me.bind(); <br>} <br>}, 6); //10 to 6 <br>}, <br>bind: function () {// <br>var me = this, st, rt; <br>window.onscroll = function () { <br>clearTimeout(st); <br>clearTimeout(me.timer2); <br>me.setOpacity(0); <br>st = setTimeout(function () { <br>me.win.style.top = me.getY().top; <br>me.show(); <br>}, 100); //600 mod 100 <br>}; <br>window.onresize = function () { <br>clearTimeout(rt); <br>rt = setTimeout(function () { me.win.style.top = me.getY().top }, 100); <br>} <br>}, <br>init: function () {// HTML <br>function $(id) { return document.getElementById(id) }; <br>this.win = $('msg_win'); <br>var set = { minbtn: 'msg_min', closebtn: 'msg_close', title: 'msg_title', content: 'msg_content' }; <br>for (var Id in set) { this[Id] = $(set[Id]) }; <br>var me = this; <br>this.minbtn.onclick = function () { me.set(); this.blur() }; <br>this.closebtn.onclick = function () { me.close() }; <br>this.char = navigator.userAgent.toLowerCase().indexOf('firefox') + 1 ? ['_', '::', '×'] : ['0', '2', 'r']; //FF webdings <br>this.minbtn.innerHTML = this.char[0]; <br>this.closebtn.innerHTML = this.char[2]; <br>setTimeout(function () {// <br>me.win.style.display = 'block'; <br>me.win.style.top = me.getY().foot; <br>me.moveTo(me.getY().top); <br>}, 0); <br>return this; <br>} <br>}; <br>Message.init(); <br>