您的位置:首页 > 运维架构 > 网站架构

后台利用JS刷新页面(网站)

2014-03-06 15:53 357 查看
1.在后台中的显示添加或修改后的提示信息(提示之后刷新当前页)

ShowMsgHelper.AlertMsg("操作成功!");

2.提示信息的原函数
  top.main.windowload();//javascript中的刷新页面代码

public static void AlertMsg(string message)
{
ShowMsgHelper.ExecuteScript(string.Format("showTipsMsg('{0}','2500','4');top.main.windowload();OpenClose();", message));
}

3.将后台的代码反应到前台的JS代码中
public static void ExecuteScript(string scriptBody)
{
string scriptKey = "Somekey";
Page p = HttpContext.Current.Handler as Page;
p.ClientScript.RegisterStartupScript(typeof(string), scriptKey, scriptBody, true);
}

4.FunctionJS.js中的相关代码
//回调
function windowload() {
rePage();
}
/**
刷新页面
**/
function rePage() {
Loading(true);
window.location.href = window.location.href.replace('#', '');
return false;
}
/**
短暂提示
msg: 显示消息
time:停留时间ms
type:类型 4:成功,5:失败,3:警告
**/
function showTipsMsg(msg, time, type) {
top.ZENG.msgbox.show(msg, type, time);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: