最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set height and width of a new window from code behind - Stack Overflow

programmeradmin3浏览0评论

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

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%');
    }
Share Improve this question asked May 14, 2013 at 13:04 Iti TyagiIti Tyagi 3,6818 gold badges51 silver badges80 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

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

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

发布评论

评论列表(0)

  1. 暂无评论