- comeon-liming
- 等级: 初级会员
- 性别:
- 文章: 9
- 积分: 30
- 来自: 大连
|
java 代码
- package com.axon.fable.empolderpackage.out;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.PrintWriter;
-
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
-
- import java.io.*;
-
-
-
-
-
-
-
-
-
-
- public class OutJavaScript {
-
- private static String include="" +
- "<script language=\"javascript\" type=\"text javascript\" src="\"/sams/samspage/js/alert/myalert.js\""></script>";
-
-
-
-
-
-
-
-
- public static void outSendNull(HttpServletResponse response,String outString,String path){
- String str="+outString+"');setTimeout(\"document.URL='"+path+"'\",\"2000\");" +
- "" +
- " "+
- ">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
-
-
- public static void outSendNull(HttpServletResponse response,HttpServletRequest request,String outString,String path){
- String str="+outString+"\");" +
- "" +
- "setTimeout(\"document.URL='"+path+"'\",\"2000\");" +
- ">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
- public static void outString(HttpServletResponse response,String outString,String backNum){
-
- String str="+outString+"'); setTimeout('history.back("+backNum+");',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
- public static void outString(HttpServletResponse response,String outString){
-
- String str="+outString+"'); setTimeout('history.back();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
-
-
-
- public static void outCloseReload(HttpServletResponse response,String outString){
-
- String str="+outString+"'); setTimeout('window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
- public static void outCloseReload2(HttpServletResponse response,String outString){
-
- String str="+outString+"'); setTimeout('opener.location.reload();window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
- public static void outClose(HttpServletResponse response,String outString){
-
- String str="+outString+"'); setTimeout('window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
- public static void outClose(HttpServletResponse response,String outString,String goPath){
-
- String str="+outString+"');setTimeout('opener.location="+goPath+";window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
-
-
-
-
-
-
-
- public static void outCloseBrower(HttpServletResponse response,String outString){
-
- String str="<script language='javascript'>" +
- " var parwin=null;" +
- "var b = \"/sams/login.jsp\";" +
- " if(parent.parent.parent.window!=null)" +
- " parwin=parent.parent.parent.window;" +
- " else if(parent.parent.window!=null)" +
- " parwin=parent.parent.window;" +
- " else if(parent.window!=null)" +
- " parwin=parent.window;" +
- "parwin.opener=null;" +
- "alert(\""+outString+"\");" +
- "window.location=b;" +
- "return;" +
- "</script>";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(str);
- out.flush();
- }
-
-
-
- public static void outCloseBrower(HttpServletResponse response,HttpServletRequest request,String outString){
-
- PrintWriter out;
- try {
- response.setCharacterEncoding("utf-8");
- out = response.getWriter();
-
- out.println("<script language='javascript'>alert('"+outString+" ');setTimeout('',2000);</script>");
-
- out.println("");
- out.println("");
- out.println("<script language=\"javascript\">");
-
-
-
- out.println("var subwin=null;");
- String oper="subwin=open('','','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,"+
- "center:yes,menubar=no,copyhistory=no,left=0,top=0,resizable=yes,"+
- "width=1024,height=768');";
-
- out.println(oper);
- out.println("if(subwin!=null)");
- out.println("{");
-
- out.println("subwin.document.location='"+request.getContextPath()+"/login.jsp';");
-
- String str=" var parwin=null; if(parent.parent.parent.window!=null)" +
- " parwin=parent.parent.parent.window;" +
- "else if(parent.parent.window!=null)" +
- "parwin=parent.parent.window; " +
- "else if(parent.window!=null)" +
- "parwin=parent.window;";
- out.println(str+"parwin.opener=null;");
- out.println("parwin.close();");
- out.println("}");
- out.println("else {");
- out.println("window.name='EasyOfficeMain';");
- out.println("document.location='"+request.getContextPath()+"/login.jsp';");
- out.println("}");
-
-
- out.println("</script>");
- out.println("");
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- }
-
-
-
-
-
- public static void reload(HttpServletResponse response,String outString){
-
- String str="+outString+"'); setTimeout('history.back();window.location.reload();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
-
- }
-
-
-
-
-
-
-
-
- public static void outString(HttpServletResponse response,HttpServletRequest request,String outString,String path){
-
- String str="";
-
- str="<script language='javascript'>if(!window.confirm('"+outString+"')){history.back();}else{" +
- "" +
- "document.location='"+path+"'; "+
- "}</script>";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
-
- } catch (IOException e) {
-
- e.printStackTrace();
- }
-
- out.println(str);
- out.flush();
-
-
- }
-
- public static void reloadWithMessageShow(HttpServletResponse response,HttpServletRequest request,String message1,String message2,boolean isSuccess){
-
-
- String str="<script language='javascript'>";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
-
- out.println(str);
- out.println("opener.alert("+'"'+""+message1+message2+""+'"'+")");
- out.println("setTimeout('opener.location.reload();',2000); ");
- out.println("window.close();");
- out.println("</script>");
-
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- out.println(str);
- out.flush();
-
- }
- public static void responseDiv(HttpServletResponse response,HttpServletRequest request,String message1,String message2,boolean isSuccess){
-
-
- BufferedReader bufread ;
- String filepath,read;
- try{
- filepath=request.getRealPath("/samspage/js/out/end.txt");
- File file=new File(filepath);
- FileReader fileread= null;
-
- fileread = new FileReader(file);
- bufread=new BufferedReader(fileread);
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- out = response.getWriter();
- while((read=bufread.readLine())!=null){
- System.out.println(read);
- out.println(read);
- }
-
- out.println(" var caption = "+'"'+"短消息提示:"+'"'+";var message = "+'"'+message1+'"'+";var title = "+'"'+message2+'"'+";");
- out.println("window.dialogHeight="+'"'+"150px"+'"'+";window.dialogWidth="+'"'+"280px"+'"'+";window.dialogLeft=screen.width/2-140;window.dialogTop="+'"'+"375px"+'"'+";var w ="+'"'+"50px"+'"'+";var h ="+'"'+"50px"+'"'+";");
-
- filepath=request.getRealPath("/samspage/js/out/responseHtml.txt");
- file=new File(filepath);
- fileread= null;
- fileread = new FileReader(file);
- bufre
- alert.rar (90.4 KB)
- 描述: 修改过的alert弹出框代码
- 下载次数: 13
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
返回顶楼 |
|
|
- duronshi
- 等级: 初级会员
- 性别:
- 文章: 168
- 积分: 20
- 来自: 深圳
|
你这个类好像运行在servlet情况下的吧?
在传递参数时,将response,request能否设一个默认值,或者判断如果没有对应参数传入时,就不用servelt?
不知个人理解对不?
还有一个小问题,就是css文件里的图片路径不对,应该取掉..之类
|
返回顶楼 |
|
|
- comeon-liming
- 等级: 初级会员
- 性别:
- 文章: 9
- 积分: 30
- 来自: 大连
|
这只是一个普通的class,我一般在action中调用使用比较频繁,页里中也会调用到.
用这种方式配合样式表与DWR使用效果相当的出色.
|
返回顶楼 |
|
|