开发者

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

开发者 https://www.devze.com 2023-04-06 06:37 出处:网络
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.

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开发者_如何学Python toggles the browser to full screen?


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消