怎么在新窗口打开html页面

beckhamzzj 2008-07-15 10:59:02
在jsp页面有个按钮,按下后,走action从后台得到数据,然后把数据输出到html页面,必须在新窗口

现在用response.getWriter()无法实现在新窗口打开

有什么解决方法吗
...全文
732 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
anly_hz 2008-07-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 anly_hz 的回复:]
response.setContentType("text/html;charset=utf-8");

PrintWriter out = response.getWriter();

out.println(" <script>");


out.println("window.open('example.jsp');");

out.println(" </script>");

out.flush();

out.close();

测试通过了,弹出了一个新窗口.
[/Quote]
上次忘记写内容了,嘿嘿,你是想向新窗口写内容是吧。

out.println("<script>");
out.println("var newwin = window.open('example.jsp');");//打开新窗口
out.println("newwin.document.write('ha ha....');");//写入haha....
out.println("</script>");
lixq2000 2008-07-16
  • 打赏
  • 举报
回复
window.open('example.jsp')
example.jsp的代码:
<html>
<head>
<title>Servlet </title>
</head>
<body>
aaaaaaaaaaaaaaaaaaaaaaaaaaa
</body>
</html>

不知道是不是这个意思。
jsgyxujian 2008-07-16
  • 打赏
  • 举报
回复
windows.open试试看,可以的
PostX 2008-07-15
  • 打赏
  • 举报
回复
对于提问很汗颜,对于回复就更汗了~
tujiyue 2008-07-15
  • 打赏
  • 举报
回复
<a href="..." target="_blank">...</a>
beckhamzzj 2008-07-15
  • 打赏
  • 举报
回复
可能我没有讲清楚啊

out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaa");
out.println("</body>");
out.println("</html>");
out.close();


我需要把这段东西在新窗口打开,老画面原样

现在只能实现,从老画面跳转到这个手写的html
anly_hz 2008-07-15
  • 打赏
  • 举报
回复
response.setContentType("text/html;charset=utf-8");

PrintWriter out = response.getWriter();

out.println("<script>");


out.println("window.open('example.jsp');");

out.println("</script>");

out.flush();

out.close();

测试通过了,弹出了一个新窗口.
ilrxx 2008-07-15
  • 打赏
  • 举报
回复
window.open试试
ee4456 2008-07-15
  • 打赏
  • 举报
回复
window.open
chengyu2099 2008-07-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xunyiren 的回复:]
如果是文件链接的话,可用target="_blank"属性
<a href="http://www.sohu.com" target="_blank">aaaaaa </a>

如果是按钮的话,用js

<input type="button" name="ck" onclick="window.open(url)"/>
[/Quote]
+JS 就可以了
JerryBeckF 2008-07-15
  • 打赏
  • 举报
回复
window.open(提交form的url);//而不是form.submit();
window.showmodaldialog()或window.showmodelessdialog()
xunyiren 2008-07-15
  • 打赏
  • 举报
回复
如果是文件链接的话,可用target="_blank"属性
<a href="http://www.sohu.com" target="_blank">aaaaaa</a>

如果是按钮的话,用js

<input type="button" name="ck" onclick="window.open(url)"/>
PostX 2008-07-15
  • 打赏
  • 举报
回复
onclick=document.Form.target="_blank";document.Form.action="XXX"}>

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧