public static string GetMsg(string strDescription)
{
string strScript = "<script language=/"javascript/">";
if(strDescription != "")
{
strScript += "document.write(/"<div id='popmsg' style='position:absolute;right:0px;bottom:0px;width:260px;height:165px;z-index:1;padding:20px 20px 20px 20px;word-break:break-all;text-align:left;background-image: url(images/popmsgbg.gif);'>"+strDescription+"</div>/");";
strScript += "j=3;"+
"function popClose() {"+
" j -= 1;"+
" if (j > 0){setTimeout(/"popClose()/",1000);}"+
" else{popmsg.style.display=/"none/";}"+
"}";
strScript += "popClose();";
}
strScript += "</script>";
return strScript;
}

本文介绍了一个使用JavaScript生成带有定时关闭功能的弹窗消息的方法。该方法通过字符串拼接生成HTML脚本,实现自定义样式的提示信息,并利用递归计数实现自动关闭效果。

被折叠的 条评论
为什么被折叠?



