struts..javascript code for pop-up window

Hi All,i have 2 jsp pages and in first i have a button add. on clicking add button, second jsp page opens as a popup window. i want ot know how to white a code in java script for this button...plzz help me ASAP..
[233 byte] By [sunildubeya] at [2007-10-3 2:53:35]
# 1
2 ways, you can either make a javascript and call the javascript in onclick method or directly call below that methodjavascript:window.open('xxxxx.jsp');
ViQuEnYeEa at 2007-7-14 20:42:37 > top of Java-index,Java Essentials,Java Programming...
# 2
Hi Sir..i don know how to and where to write the code along with my button tag code..<html:button><bean:message key="button.add"/> </html:button>
sunildubeya at 2007-7-14 20:42:37 > top of Java-index,Java Essentials,Java Programming...
# 3

Hi,

Follow Following Steps

-

1) Create scripts.js file and add following content

function popupaddpackage(urlToOpen) {

var window_width = screen.availWidth/5;

var window_height = screen.availHeight/5;

var window_left = (screen.availWidth/2)-(window_width/2);

var window_top = (screen.availHeight/2)-(window_height/2);

var winParms = "fullscreen=no"+",location=no"+",menubar=no"+",titlebar=no"+",toolbar=no"+",Status=no" + ",resizable=no" + ",height="+window_height+",width="+window_width + ",left="+window_left+",top="+window_top;

var newwindow = window.open(urlToOpen,'_blank',winParms);

newwindow.focus()

}

2) Create any JSP, like test,jsp and add following content

**************************************************************

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>

<head><title>Simple jsp page</title></head>

<body>Place your content here in test.jsp</body>

</html>

3) Now call your javascript file , so create index.jsp and add following contents

--

<%@ page import="org.apache.struts.action.ActionErrors" %>

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

<HTML>

<script LANGUAGE="JavaScript" SRC="scripts.js"></script>

<BODY>

<html:form action="/actions/showSample">

<TABLE ALIGN="CENTER" CELLPADDING=0 CELLSPACING=0>

<TR>

<TD>

<html:submit onclick="popupaddpackage('test.jsp')" value="Add Package" style="height:23;width:100"/>

</TD>

</TR>

</TABLE>

</html:form>

</BODY></HTML>

Hope you got it, please let me know if you faced problem

--

Amit Pandya

amitpandya75@gmail.com

aMiTa at 2007-7-14 20:42:37 > top of Java-index,Java Essentials,Java Programming...