<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>  <head>
    <title>My JSP 'error.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<%
String redirecturl=(String)request.getAttribute("redirecturl");
%>  <script language="javascript">
         //这一行执行不过去。
  var redirecturl='<%=redirecturl%>';
  function  redirecturl()
  {
    alert("redirecturl=");
    window.location.href=this.redirecturl;
  }
 
  </script>
  </head>
  
  <body>
  <%=redirecturl %><br/>
   <%=request.getAttribute("responseText") %><br/>
       <input type="button" name="buttonl" value="确定" onClick="redirecturl()">
     <input type="button" value="取消"/>
  </body>
</html>var redirecturl='<%=redirecturl%>' 我调测了很久 发现这行执行不过去。没写错啊。我也换了${}的方法。还是有问题。
redirecturl 是可以取到的有值的。

解决方案 »

  1.   

     alert("redirecturl=");
              window.location.href=this.redirecturl
    redirecturl 能取到值吗?
    不能赋给window.location.href?
      

  2.   

    换成它var redirect="<%=redirecturl%>";试试
      

  3.   

    function  redirecturl()
         {
              alert("redirecturl=");
              window.location.href=redirecturl;
         }
    window.location.href=redirecturl;这块不用加this
      

  4.   

    <script language="javascript">
             //这一行执行不过去。
         var redirecturlVar='<%=redirecturl%>';
         function  redirecturl()
         {
              alert("redirecturl=");
              window.location.href=redirecturlVar;
         }
         
         </script>第一变量别跟函数名重名
    第二window.location.href=redirecturlVar;这句不用加this
      

  5.   


    var redirecturl="<%=(String)request.getAttribute("redirecturl");%>";为什么不直接这样.