如何从后面的代码设置新窗口的高度和宽度 [英] How to set height and width of a new window from code behind
问题描述
我一直在尝试打开新窗口几个小时,而且我一定会从后面的代码启动,因此它不会在新标签页中打开.我想调整此窗口的高度和宽度,但无法设置相同的值.我还尝试过从后面的代码中调用javascript函数,并在aspx页面中编写相同的函数,但是没有运气.
I have been trying this from hours that I am opening a new window and I am bound to launch from code behind so it is not opening in new tab. I want to adjust the height and width of this window, but I am unable to set the same. I also tried calling a javascript function from code behind and writing the same in aspx page, but no luck.
我正在发布我的代码:在后面的代码中:
I am posting my code: From Code behind:
Page.ClientScript.RegisterStartupScript(typeof(string), scriptKey, "<script type='text/javascript'>window.open('../ReportWebForm.aspx?ReportType=Report','height=50,width=2000,left=0px,top=0px,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');</script>");
如果我是通过调用aspx页面javascript从服务器启动的:
if I launch from server by calling aspx page javascript:
function OpenWindow() {
window.parent.open('../ReportWebForm.aspx?ReportType=Report', 'width = 100%, height = 100%');
}
推荐答案
尝试一下
注意第二个参数是窗口的名称.您需要在第三个参数中输入的高度和宽度
note 2nd parameter is name of window. the height and width you need to give in 3rd parameter
function OpenWindow() {
window.open('../ReportWebForm.aspx?ReportType=Report','', 'width = 100, height = 100');
}
这篇关于如何从后面的代码设置新窗口的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!