在同一页面内以小尺寸打开一个新窗口 [英] open a new window inside same page in a small size

查看:233
本文介绍了在同一页面内以小尺寸打开一个新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jsp page,当单击submit button时,会在同一页面中打开一个新页面,但我想要的是new page(window)应该打开inside same page,但尺寸要小于您在中看到的许多网站. after clicking submit button a new page will be opened in a less size,我该如何使用jquery/javascript来做到这一点?

i have a jsp page and when clicking on submit button, a new page is opened in same page but what i want is that new page(window) should open inside same page but having less size as like you would have seen in many websites. after clicking submit button a new page will be opened in a less size, how can i do it using jquery/javascript?

index.jsp

<form action="newwindow.jsp" target="_self">
<input type="submit value="click here"/>
</form>

请提出任何想法

推荐答案

下面应该使用您的示例代码,以为您在寻找target ="_ blank",而不是_self,因为_self是同一窗口,具有相同的效果完全没有目标值.另外,不要以为最近几天鼓励使用target ="_ blank",加上标签式浏览器,它只会在新标签页中打开,并且无法调整大小.

Below should work with your sample code, think you were looking for target="_blank", not _self as _self is the same window and has same effect of having no target value at all. Also dont think that target="_blank" is encouraged much these days, plus with tabbed browsers it will just open in a new tab and not be re-sizeable.

希望以下内容对您有所帮助

Hopefully the below helps

<form target="popup" action="google.com" onsubmit="window.open('', this.target,    'width=300,height=300,resizable,scrollbars=yes'); return true;">
<input type="submit" value="click here"/>
</form>

基于尝试使弹出窗口居中的新示例代码.

New sample code based on trying to center the pop-up.

我认为这个问题令人困惑,因为不清楚弹出窗口是否正在访问服务器端内容以及是否需要访问表单内容.根据您的情况,针对此问题提供的其他答案也可能适合您.下面是我的修改后的代码,希望它会有所帮助,但不能100%确定,因为上下文有点混乱

I think the quesiton is confusing though as its not clear if the popup is accessing server side stuff or not and if it needs access to the form contents. The other answer offered for this question could also suit you based on your circumstance. Below is my revised code, hopefully it will help but not 100% sure as the context is a little confusing

<script>
function openWindow(h, w, url) {
  leftOffset = (screen.width/2) - w/2;
  topOffset = (screen.height/2) - h/2;
  window.open(url, this.target, 'left=' + leftOffset + ',top=' + topOffset + ',width=' + w + ',height=' + h + ',resizable,scrollbars=yes');

}
</script>
<form name="form2" id="form2" method="post" action="google.com" onsubmit="openWindow(300, 300, 'google.com');">
<input type="submit" value="click here"/>
</form>

这篇关于在同一页面内以小尺寸打开一个新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆