How to set height and width of a new window from code behind

房东的猫 提交于 2021-01-28 18:51:55

问题


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>");

if I launch from server by calling aspx page javascript:

 function OpenWindow() {
        window.parent.open('../ReportWebForm.aspx?ReportType=Report', 'width = 100%, height = 100%');
    }

回答1:


Try this

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');
    }



回答2:


You can try this.

  <a href="javascript:;" style="color:#000"  onClick="window.open('printreport3.php','msgWindow','toolbar=no, scrollbars=yes, resizable=no, top=30, left=100, width=1000, height=auto')"> Print View </a>

you have to set scrollbar to yes. scrollbars=yes



来源:https://stackoverflow.com/questions/16543971/how-to-set-height-and-width-of-a-new-window-from-code-behind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!