我想做类似开心网001那样的效果,有好友消息,标题栏闪动。
前台代码:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel> 后台代码:
protected void Timer1_Tick(object sender, EventArgs e)
{
if (j % 3 == 0)
{
this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
this.UpdatePanel1.Update();
}
j++; }JS代码如下:
<script type="text/javascript">
var g_blinkswitch = 0;
var g_blinktitle = document.title;
function blinkNewMsg()
{
document.title = g_blinkswitch % 2==0 ? "【 】 - " + g_blinktitle : "【新消息】 - " + g_blinktitle;
g_blinkswitch++;
}
function blink()
{
setInterval(blinkNewMsg, 1000);
}
</script> 求助各位高手......
代码很简单,每30秒闪动10秒,10秒timer一下
前台代码:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel> 后台代码:
protected void Timer1_Tick(object sender, EventArgs e)
{
if (j % 3 == 0)
{
this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
this.UpdatePanel1.Update();
}
j++; }JS代码如下:
<script type="text/javascript">
var g_blinkswitch = 0;
var g_blinktitle = document.title;
function blinkNewMsg()
{
document.title = g_blinkswitch % 2==0 ? "【 】 - " + g_blinktitle : "【新消息】 - " + g_blinktitle;
g_blinkswitch++;
}
function blink()
{
setInterval(blinkNewMsg, 1000);
}
</script> 求助各位高手......
代码很简单,每30秒闪动10秒,10秒timer一下
解决方案 »
- 访问网络文件时出现返回1203,请教解决原因!!![
- ASP.NET MVC框架下 GZip压缩问题
- OA里的日程管理做不出来谁能帮帮我
- 问个简单的问题:ASP.NET中怎么调用别的.cs文件中的代码
- vs 2005的Table服务器控件动态添加用户控件 高手请进~~~~~~~~~~~
- ASP.NET如何抓取深交所中的各个公司利润表、资产负债表数据
- 定时访问数据库(ASP+SQL)
- ------------Render()方法什么时候执行?由谁执行?------------
- 求助~~~ASP.NET用户控件中GridView的问题
- 有关页面刷新的简单问题大家讨论一下
- orcale数据访问
- 关于图片热点链接的问题
var step=0; //计数器变量,初始值为0
function flash_title(){
step++; //变量递增
if (step==3) {step=1}; //两种变化,所以大于3时回到1
if (step==1) {document.title='\(^o^)/~开心网'}; //标题一
if (step==2) {document.title='◎开心网'}; //标题二
setTimeout("flash_title()",1000); //每一秒钟变换一次
}
flash_title(); //调用函数自身
</script>
设置一个开关,或在<body>里用onLoad装载函数,样式为:onLoad="flash_title()"。
var step = 0;
var st = null;
function flash_title() {
if (step == 5) { step = 0 }
if (step == 0) { document.title = '☆☆☆☆★☆☆☆☆' }
if (step == 1) { document.title = '☆☆☆★☆★☆☆☆' }
if (step == 2) { document.title = '☆☆★☆☆☆★☆☆' }
if (step == 3) { document.title = '☆★☆☆☆☆☆★☆' }
if (step == 4) { document.title = '★☆☆☆☆☆☆☆★' }
step++
st = setTimeout("flash_title()", 30);
}
window.onfocus = function() {
if (st != null)
clearTimeout(st);
}
window.onblur = function() {
flash_title();
}
</script>
</body>
</html>
protected void Timer1_Tick(object sender, EventArgs e)
{
DataSet ds = B_Showmessage.getAllUnReadMsg();
if (ds != null && ds.rows.count >0)
{
this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
this.UpdatePanel1.Update();
}
}
如果不把Timer放入updatepanel中,页面就会刷新,闪动我是希望无刷新得让标题栏闪动
把this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
换成:
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.UpdatePanel1.GetType(), "msg", "blink();", true); 谢谢各位了