js文件如下:
var dynamicMsg = null;
function init() {
dynamicMsg = new DynamicMessage(window.document.title, "【新消息】", "【 】");
} function begin() {
dynamicMsg.initIntervalMsg();
} function end() {
dynamicMsg.clearIntervalMsg();
} /**
* 处理新消息提示的操作
*/
function DynamicMessage(defaultMsg, msg, hiddenMsg) {
this.initIntervalMsg = function() {
this.intervalMsg = setInterval(function() {
if(!this.bMsg) {
window.document.title = msg + " - " + defaultMsg;
this.bMsg = true;
} else {
window.document.title = hiddenMsg + " - " + defaultMsg;
this.bMsg = false;
}
},
1000
);
};
this.clearIntervalMsg = function() {
if(this.intervalMsg != null) {
clearInterval(this.intervalMsg);
window.document.title = defaultMsg;
this.bMsg = false;
}
};
}aspx文件如下:
<body onload="init();"> <form id="form1" runat="server">
<div>
<center>
<input type="button" value="begin" onclick="begin();"/>
<input type="button" value="end" onclick="end();"/>
<br />
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<br/>
</center>
</div>
</form>
</body>aspx.cs文件如下:
protected void Button1_Click(object sender, EventArgs e)
{
//Page.RegisterClientScriptBlock("", "<script language='javascript'>begin()</script>");
this.ClientScript.RegisterStartupScript(typeof(string), "js", "begin();", true);
}调试过程中,input按钮没有问题button按钮无法完成功能,提示“错误: 'dynamicMsg' 为空或不是对象”
哪位高手知道啊?
var dynamicMsg = null;
function init() {
dynamicMsg = new DynamicMessage(window.document.title, "【新消息】", "【 】");
} function begin() {
dynamicMsg.initIntervalMsg();
} function end() {
dynamicMsg.clearIntervalMsg();
} /**
* 处理新消息提示的操作
*/
function DynamicMessage(defaultMsg, msg, hiddenMsg) {
this.initIntervalMsg = function() {
this.intervalMsg = setInterval(function() {
if(!this.bMsg) {
window.document.title = msg + " - " + defaultMsg;
this.bMsg = true;
} else {
window.document.title = hiddenMsg + " - " + defaultMsg;
this.bMsg = false;
}
},
1000
);
};
this.clearIntervalMsg = function() {
if(this.intervalMsg != null) {
clearInterval(this.intervalMsg);
window.document.title = defaultMsg;
this.bMsg = false;
}
};
}aspx文件如下:
<body onload="init();"> <form id="form1" runat="server">
<div>
<center>
<input type="button" value="begin" onclick="begin();"/>
<input type="button" value="end" onclick="end();"/>
<br />
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<br/>
</center>
</div>
</form>
</body>aspx.cs文件如下:
protected void Button1_Click(object sender, EventArgs e)
{
//Page.RegisterClientScriptBlock("", "<script language='javascript'>begin()</script>");
this.ClientScript.RegisterStartupScript(typeof(string), "js", "begin();", true);
}调试过程中,input按钮没有问题button按钮无法完成功能,提示“错误: 'dynamicMsg' 为空或不是对象”
哪位高手知道啊?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货