How to open a browser in full screen in ASP.NET application programmatically?

痴心易碎 提交于 2019-12-13 06:51:50

问题


I am making a web application in ASP.NET 4.0. For some reason I need to open a web site always in full screen. It is a tedious task to open a web site in browser and then toggle to fullscreen.

Is there any way to open the browser (preferably IE9 or Google Chrome) in full screen programmatically? Can I put some code in the Page_Load() method of my default page that toggles the browser to full screen?


回答1:


The only way to manipulate the window size for a web app is through javascript, and so that will need to be a requirement for your page/site. Even here, you have three challenges:

  1. Some browsers provide an option to disable this particular feature of javascript
  2. I can't recall a way off the top of my head to see from javascript how big the screen really is, and how much of that space will be taken up by the browser chrome. I suspect it's not possible to know.
  3. There is no way to hide all of the browser chrome.

Parts of those challenges are there for security reasons, to prevent malicious web sites from hijacking user's screens, and therefore they will be no workaround.




回答2:


I'd suggest embeding a javascript function into your ASP.NET code. use window.open() and then pass the proper parameters. I used something comparable of embedding javascript into .net with Response.Write. This example method below does window.open. Just push the proper parameters and URL, etc.

The parameters btw are : 'http://URL', 'Title' , 'type=fullWindow, fullscreen, scrollbars=yes'

private void MessageBox(string URL, string parameters)
 {
     if (!string.IsNullOrEmpty(URL))
     {
         Response.Write
      ("<script type=\"text/javascript\" language=\"javascript\">");
         Response.Write("window.open('" + URL + parameters + "');");
         Response.Write("</script>");
     }
 }


来源:https://stackoverflow.com/questions/7503704/how-to-open-a-browser-in-full-screen-in-asp-net-application-programmatically

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