이 기사에서는 Zhongguancun Forum Score를 모방 한 후 팝업 프롬프트 효과를 달성하기위한 JS 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
코드를 다음과 같이 복사하십시오.
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<title> js 모방 Zhongguancun Forum의 효과 팝업 프롬프트 </title>
</head>
<body>
<script language = "javaScript">
var x = window.x || {};
x.creat = function (t, b, c, d) {
this.t = t;
this.b = b;
this.c = c;
this.d = d;
this.op = 1;
this.div = document.createElement ( "div");
this.div.style.height = "40px";
this.div.style.width = "100px";
this.div.style.background = "빨간색";
this.div.style.position = "절대";
this.div.style.left = "50%";
this.div.style.marginleft = "-50px"
this.div.style.margintop = "-20px"
this.div.innertext = "참여해 주셔서 감사합니다! 경험 +5"
this.div.style.fontsize = "12"
this.div.style.lineheight = this.div.style.height
this.div.style.textalign = "Center";
this.div.style.fontweight = "Bold";
//this.div.style.border="solid red 1px ";
this.div.style.color = "#fff"
this.div.style.top = (this.b+"%");
document.body.appendchild (this.div);
this.run ();
}
x.creat.prototype = {
실행 : function () {
var me = 이것;
this.div.style.top = -this.c*(this.t/this.d)*(this.t/this.d)+this.b+"%";
this.t ++;
this.q = settimeout (function () {me.run ()}, 25)
if (this.t == this.d) {
클리어 타임 아웃 (me.q);
settimeout (function () {me.alpha ();}, 1000);
}
},
알파 : function () {
var me = 이것;
if ( "/v"== "V") {
this.div.style.filter = "progid : dximagetransform.microsoft.alpha (불투명 ="+this.op*100+")";
this.div.style.filter = "alpha (불투명 ="+this.op*100+")";
;}
else {this.div.style.opacity = this.op}
this.op- = 0.02;
this.w = settimeout (function () {me.alpha ()}, 25)
if (this.op <= 0) {
클리어 타임 아웃 (this.w);
document.body.removechild (me.div);
}
}
}
새로운 X.Creat (1,50,25,30);
</스크립트>
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.