利用history.go页面返回
2010-12-09 20:24
363 查看
开发中经常遇到页面返回的问题,可以有很多种处理方法,我在这里讲一种通用的,简便方法,可以在刷新页面后返回依然有效
//基类
/// <summary>
/// 记录提交页面次数,用在javascript:history.go(<%=GoNum%>)
/// </summary>
public int GoNum
{
get
{
if (this.ViewState["GoNum"] == null)
{
this.ViewState["GoNum"] = "-1";
return -1;
}
else
{
return Convert.ToInt32(this.ViewState["GoNum"]);
}
}
set
{
this.ViewState["GoNum"] = value.ToString();
}
}
/// <summary>
/// 更新数据后返回页数加1
/// </summary>
public void IncreaseGoNum()
{
GoNum += -1;
}
//父页面Page_Load事件
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
IncreaseGoNum();
}
}
//父页面跳转
Redirect(string.Format("Sample.aspx?ID={0}&GoNum={1}", ID, GoNum + 1));
//子页面Page_Load事件
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GoNum = GetIntFromPage("GoNum");
}
else
{
IncreaseGoNum();
}
}
//使用
<a href="#" class="return" onclick="history.go(<%=GoNum%>)">返回</a>
//基类
/// <summary>
/// 记录提交页面次数,用在javascript:history.go(<%=GoNum%>)
/// </summary>
public int GoNum
{
get
{
if (this.ViewState["GoNum"] == null)
{
this.ViewState["GoNum"] = "-1";
return -1;
}
else
{
return Convert.ToInt32(this.ViewState["GoNum"]);
}
}
set
{
this.ViewState["GoNum"] = value.ToString();
}
}
/// <summary>
/// 更新数据后返回页数加1
/// </summary>
public void IncreaseGoNum()
{
GoNum += -1;
}
//父页面Page_Load事件
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
IncreaseGoNum();
}
}
//父页面跳转
Redirect(string.Format("Sample.aspx?ID={0}&GoNum={1}", ID, GoNum + 1));
//子页面Page_Load事件
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GoNum = GetIntFromPage("GoNum");
}
else
{
IncreaseGoNum();
}
}
//使用
<a href="#" class="return" onclick="history.go(<%=GoNum%>)">返回</a>
相关文章推荐
- 2017-6-14 关于使用history.go的问题!配合原生应用嵌入H5页面(只有一个webview的的单页应用)返回历史列表记录的问题
- window.history.go(-1)返回且刷新页面
- window.history.go(-1)返回且刷新页面
- 用history.go(-1)返回上一页,实现上一页页面刷新
- html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
- 利用TMG访问Connect.qq.com子页面时无法正常返回页面
- window.history.go(-1)返回上页的同时刷新"上页"技术
- html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
- 利用java.net包访问网络,连接网页并返回html页面代码
- session_start()导致history.go(-1)返回时无法保存表单数据的解决方法
- js 判断 当页面无法回退时(history.go(-1)),关闭网页
- html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
- 当一个页面跳到此页面时,它就会记录跳到这个页面的URL,然后利用这个URL返回.小技巧,记录下来
- javascript 返回上一页面:onclick="javascript:history.back(-1);"
- javascript:history.go(-1)返回上一页时,网页已过期
- IE6在<a>标签中使用history.go(-1)返回上一页无效
- window.history.go()返回上页的同时刷新"上页"代码
- js 判断 当页面无法回退时(history.go(-1)),关闭网页
- html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
- android Webview中注入js,用于解决第三方页中出现返回事件window.history.go(-1),无法响应问题