2009-06-05 24 views
0

我在那裏我得到會話值然後調用通過JavaScript表單操作頁面,請參見下面設置窗口大小與JavaScript表單行動

<%@ Page language="c#" AutoEventWireup="false" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html> 
    <head> 
    <title>SessionRedirect</title> 
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> 
    <meta name="CODE_LANGUAGE" Content="C#"> 
    <meta name=vs_defaultClientScript content="JavaScript"> 
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> 
    </head> 
    <body MS_POSITIONING="GridLayout">  
    <form method="post" name="frmRedirect" target="_blank"> 
     <input type="hidden" name="email" value="<%=Session["Email"].ToString() %>" /> 
     <input type="hidden" name="pass" value="<%= Session["PWD"].ToString() %>" /> 
     <input type="hidden" name="User" value="<%= Session["User"].ToString() %>" /> 
    </form> 
<script type="text/javascript"> 
    if(frmRedirect.User.value == "P") 
     {  
     frmRedirect.action = "http://cmsstag/partnerzone/index.aspx";  
     } 
    else 
     frmRedirect.action = "http://cmsstag/studentportal/index.aspx"; 

    document.frmRedirect.submit(); 
    location.replace("index.aspx"); 

</script> 
<% 
      Session.Remove("registration"); 
      Session.Remove("User"); 
      Session.Remove("UserId"); 
      Session.Remove("UserLoggedIn"); 
      Session.Remove("AgentCode"); 
      Session.Abandon(); 
%> 
    </body> 
</html> 

代碼現在我想和大小的新窗口中打開頁面當我使用上述代碼中使用的「frmRedirect.action」時,由我給出。

+0

是否要在新窗口中打開此窗體或窗體的操作? – 2009-06-05 07:42:34

+0

我想用窗體動作打開新窗口 – 2009-06-05 07:44:07

回答

3

這是一個相當複雜的例子。 什麼你可以嘗試是:

  1. 首先打開一個新窗口使用JavaScript window.open()並設置其尺寸和名稱
  2. 表單提交給它設置正確的目標名稱與您在window.open()設置

我試過了。有用。

編輯
這是你的代碼。也許你需要在打開一個新窗口和提交表單以確保窗口已經創建(使用setTimeout)之間設置一些時間。

// open a new window with proper size  
window.open("", "MySubWindow", "height=480,width=640"); 

// do your action assignments 

frmRedirect.target = "MySubWindow"; 
frmRedirect.submit(); 
location.replace("index.aspx");