JavaScript 页面跳转常用代码

来源:互联网 发布:linux读法 编辑:程序博客网 时间:2024/06/05 18:59

 Button1.Attributes.Add("onclick","return confirm(’确认?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")


btnClick.Attributes.Add("onclick", "return confirm('Are you sure?');");

现在在ASP.NET 2.0中,只要使用客户端的代码就可以拉,新多了个onclientclick,这样写
<asp:button id="btnClick" runat="server" OnClientClick="return confirm('Are you sure?');" text="Button"></asp:button>

允许 ASP.NET 服务器控件在 Page 中发出客户端脚本块:
    public virtual void RegisterStartupScript(string key,string script);

2.确定与取消选择不同的页

<script language="javascript">
function delit()
{
   result="确认要删除?/r/n/r/n同时会删除相关的信息!"
   if (confirm(result))
   {
     window.location.href="a1.asp"
   }
   else
   {
     window.location.href="a2.asp"
    }
}
</script>
<a href="javascript:delit()">删除</a>
javascript页面跳转常用代码

按钮式:

  <INPUT name="pclog" type="button" value="GO" onClick="location.href='http://9ba.cn/'">

  链接式:

  <a href="javascript:history.go(-1)">返回上一步</a>

  <a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>

  直接跳转式:

  <script>window.location.href='http://www.9ba.cn';</script>

  开新窗口:

  <a href="javascript:" onClick="window.open('http://www.9ba.cn/post/235.html','','height=500,width=611,scrollbars=yes,status=yes')">云上的日子</a>

提示成功后转到别的页面
Response.Write("<script>window.alert('提示语句');window.location='abc.aspx'</script>");

Response.Write("<script>window.alert('提示语句');location.href='abc.aspx';</script>");

string str="<script language='javascript'>alert('省局数据不能进行修改!');</script>";
Page.RegisterStartupScript("dd",str);

不允许后退。

Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
就可以使页面的缓存失效,每次都需要获取新页面。



<script>history.forward();</script>



    举例如下:
    if(!this.IsStartupScriptRegistered("hello"))
        this.RegisterStartupScript("hello","<script>alert('你好!')</script>"); 

原创粉丝点击