Twitter通知ajax吧,他们是怎么做到的?

mrb*_*lah 7 asp.net twitter ajax jquery

我正试图让那个很酷的,ajax滑动条有twitter(它有点透明,白色).

我试着查看html/css,但似乎它们动态地注入各种DOM层.

有人知道他们是如何实现的吗?

我真的想学习如何做到这一点.

ekh*_*led 16

在firebug或document.ready()上运行此代码

$("<div id='notification'>Notification text here</div>").css({
position:"fixed",
top:"0px",
left:"0px",
height:"20px",
width:"100%",
backgroundColor:"#cccccc",
color:"blue",
padding:"5px",
fontWeight:"bold",
textAlign:"center",
opacity:"0.5"
})
.appendTo("body");
Run Code Online (Sandbox Code Playgroud)

你应该有一个即时通知栏......

如果您熟悉jQuery(我假设您是这样,因为问题用jquery标记),您可以调整CSS和HTML值以满足您的需求......

要让它向下滑动你会这样做:

$("<div id='notification'>Notification text here</div>").css({
position:"fixed",
top:"0px",
left:"0px",
height:"20px",
width:"100%",
backgroundColor:"#cccccc",
color:"blue",
padding:"5px",
fontWeight:"bold",
textAlign:"center",
display:"none", //<-- notice this new value
opacity:"0.5"
})
.appendTo("body");
$("#notification").slideDown("slow"); //<-- this is the animation code
Run Code Online (Sandbox Code Playgroud)

免责声明:只是一个快速的事情我掀起,如果它在IE中不起作用也不会感到惊讶