Skip to main content

页面元素渐入渐出的javascript代码

Firefox only

javascirpt:

function OpacityElement(element)
{
this.targetElement = element;
this.opacity = 1.0;
this.display = null;
}

OpacityElement.prototype =
{
intervalFun: null
,
timeoutFun: null
,
handleEvent: function(t)
{
switch(t)
{
case 1:
this.opacity -= 0.04;
this.targetElement.style.opacity = this.opacity;
break;
case 2:
this.opacity = 0.0;
this.targetElement.style.opacity = 0.0;
this.display = this.targetElement.style.display;
this.targetElement.style.display = 'none';
clearInterval(this.intervlaFun);
clearTimeout(this.timeoutFun);
break;
case 3:
this.opacity += 0.04;
this.targetElement.style.opacity = this.opacity;
break;
case 4:
this.opacity = 1.0;
this.targetElement.style.opacity = 1.0;
clearInterval(this.intervlaFun);
clearTimeout(this.timeoutFun);
break;
}
}
,
Hidden: function()
{
var self = this;
this.intervlaFun = setInterval( function() { self.handleEvent(1); }, 41);
this.timeoutFun = setTimeout( function() { self.handleEvent(2); }, 1000);
}
,
Show: function()
{
var self = this;
this.targetElement.style.display = this.display;
this.intervlaFun = setInterval( function() { self.handleEvent(3); }, 41);
this.timeoutFun = setTimeout( function() { self.handleEvent(4); },
1000);
}
}

}

在html中的使用

<script type="text/javascript">
var op = new OpacityElement(document.getElementById('itemId'));
document.getElementById('btnHidden').addEventListener('click', function () { op.Hidden();
}, false);
document.getElementById('btnShow').addEventListener('click', function () { op.Show();
}, false);
</script>

Comments

Popular posts from this blog

Python中的self

习惯上,任何Python类方法的第一个参数(对当前实例d的引用)都叫做self。这个参数扮演着C++或Java中的保留字this的角色,但self在Python中并不是一个保留字,它只是一个命名习惯。虽然如此,也请除了self之外不要使用其它的名字,这是一个非常坚固的习惯。 出自:《Dive Into Python》

asp.net Single Sign-On(SSO) from SAP

公司的主系统是SAP的东西,有的时候老板想要一些小的新功能或是某个部门需要一个自己使用的小系统又不想买SAP的东西(贵啊),只有自己写和使用一些第三方免费或是开源的系统,这个时候就难免涉及到 Single Sign-On 。而在asp.net 2.0下是非常容易实现的。有SAP提供的“Sapsecu.dll”,“sapssoext.dll”2个dll再加上由公司SAP系统提供的"verify.pse"就足够了。 第一步 复制Sapsecu.dll到system32目录,并使用Rersrv32注册。 第二步 在项目里添加对sapssoext.dll的引用,vs2005会自动生成Interop.SAPSSOEXT.dll来让.net使用。 第三步 在你项目的根目录创建sap目录,并将SAP系统那边提供的verify.pse复制过去。位置倒到不是一定要在这里,只要你找得到就好。 第四步 在SAP系统那边,需要生成一个类似:http://yourserver/login.aspx?sso=werwerwerwe的链接,当然具体的页面需要你和那边的管理员商量来决定。这个链接是有时效性的,我在做测试的时候他们给的测试链接通常只能用一天。现在我们要做到就是我们这边的编码,在login.aspx的page_load里面实现: protected void Page_Load(object sender, EventArgs e) {   string sso= Request.QueryString["sso"];   SAPSSOEXT.SSO2Ticket objSSO = new SAPSSOEXT.SSO2Ticket();   objSSO.CryptLib = "sapsecu.dll";   string strKeypath = Server.MapPath("~/sap/verify.pse");    //放在根目录比较容易找   object tt;   tt = objSSO.EvalLogonTicket(strTicket, strKeypath, String.Empty); ...

Google Notebook整合了Google 书签

FF上一直装有Google笔记本的插件,一直没有到一面上去看,今天无意点到。发现多了个叫“Unfiled”的记事本,记得自己并未建过这么个东西,进去一看才发现,其实就是我的Google书签: 并且右下角也多了“Labels”,且与我Google书签中的相同。 其实人家的右上角的“ New features! ”里说得很清楚: Integration with Google Bookmarks Notebook is now integrated with Google Bookmarks. Your bookmarks will show up as a special Unfiled notebook, making Google Notebook a single place to collect and organize interesting web pages. To publish and collaborate, just drag and drop bookmarks into notebooks.