window.location.reload();页面实现跳转和刷新
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
这几个都可以刷新
window.location.reload();刷新
window.location.href=window.location.href;刷新
window.close();关闭窗口,不弹出系统提示,直接关闭
window.close()相当于self属性是当前窗口
window.parent.close()是parent属性是当前窗口或框架的框架组
页面实现跳转的九种方法实例:
<html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title>navigate</title>
< script language="javascript">
setTimeout('window.navigate("top.html");',2000);
setTimeout('window.document.location.href="top.html";',20 00);
setTimeout('window.document.location="top.html";',2000);
setTimeout('window.location.href="top.html";',2000);
setTimeout('window.location="top.html";',2000); setTimeout('document.location.href="top.html";',2000);
setTimeout('document.location="top.html";',2000);
setTimeout('location.href="top.html";',2000);
setTimeout('location.replace("top.html")',2000);
//window对象
//document对象
//location对象
//href属性
//1.window.document.location.href
//2.window.document.location
//3.window.location.href
//4.window.location
//5.document.location.href
//6.document.location
//7.location.href
//8.window.navigate
//9.location.replace
//只要使用location方法,和任意的window对象,location对象,href属性连用,都可以页面的跳转////
< /script>
< /head>< body>
页面将在2秒后跳转
< /body>
< /html>解释:
location是个对象,比如本页的document.location和window.location的属性有
location.hostname = https://www.wendangku.net/doc/2d10032388.html,
location.href =
https://www.wendangku.net/doc/2d10032388.html,/Expert/topic/4033/4033372.xml ?temp=2.695864E-02 location.host = https://www.wendangku.net/doc/2d10032388.html,
location.hash =
location.port =
location.pathname =
/Expert/topic/4033/4033372.xml
location.search = ?temp=2.695864E-02 location.protocol = http:
可见href是location的属性,类别是string。
一.使用QueryString 使用QueryString在页面间传递值是一种非常常见的方法,我们在ASP中就常常用到。 (1)优点和缺点优点: 优点:1.使用简单,对于安全性要求不高时传递数字或是文本值非常有效。 缺点:1.缺乏安全性,由于它的值暴露在浏览器的URL地址中的。 2.不能传递对象。 (2)使用方法 1.在源页面的代码中用需要传递的名称和值构造URL地址。 2.在源页面的代码用Response.Redirect(URL);重定向到上面的 URL地址中。 3.在目的页面的代码使用Request.QueryString["name"];取出 URL地址中传递的值。 (3)应用举例 1.源页面*.aspx的代码: private void Button1_Click(object sender, System.EventArgs e) { String urlAddress; string Name1; string Name2; string Name3; string Name1Value = "HelloName1"; int Name2Value = 1234567; string Name3Value = "你好名称3"; urlAddress="destinationWebForm.aspx?Name1=" + Name1Value + "&" + "Name2=" + Name2Value.ToString() + "&" + "Name3=" + Name3Value; Response.Redirect(urlAddress); } 2.目的页面destinationWebForm.aspx的代码: private void Page_Load(object sender, System.EventArgs e) { String myName1Value; int myName2Value; string myName3Value; myName1Value = Request.QueryString["Name1"]; myName2Value=Convert.ToInt32(Request.QueryString["Name 2"]); myName3Value = Request.QueryString["Name3"]; } (4)可能出现的问题1在处理Resonse.QueryString函数汉字参数传递时,发生不能完整传递参数的具体值的错误,解决有两个方法。
servlet跳转页面的几种方法 一直对Servlet的几种页面跳转方式,理解的糊里糊涂的,今天在网上搜了一把,找到一遍比较好的,记下来,以后看看。 跳转分两部分,一是发生在servlet,一是在JSP,其实JSP也就是servlet,不过还是有点差异滴。 Servlet: 当然,在servlet中,一般跳转都发生在doGet, doPost等方法里面。 1) redirect 方式 response.sendRedirect("/a.jsp"); 页面的路径是相对路径。sendRedirect可以将页面跳转到任何页面,不一定局限于本web应用中,如: response.sendRedirect("https://www.wendangku.net/doc/2d10032388.html,"); 跳转后浏览器地址栏变化。 这种方式要传值出去的话,只能在url中带parameter或者放在session中,无法使用request.setAttribute来传递。 2) forward方式 RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp"); dispatcher .forward(request, response); 页面的路径是相对路径。forward方式只能跳转到本web应用中的页面上。 跳转后浏览器地址栏不会变化。 使用这种方式跳转,传值可以使用三种方法:url中带parameter,session,request.setAttribute JSP: 1) response.sendRedirect(); 和servlet的response.sendRedirect()方式一样。 此语句前不允许有out.flush(),如果有,会有异常: https://www.wendangku.net/doc/2d10032388.html,ng.IllegalStateException: Can't sendRedirect() after data has committed to the client.
1、在HTML中,()标记不可出现在
和标记符之间。(C) (A)