Javascript full screen display code

Source: Internet
Author: User
Tags close page

First:

On a common web page that has been opened, click "full screen" and enter the full screen mode corresponding to the web page. Method: Add the following code between the <body> and </body> Of the webpage:

<Form>
<Input type = "BUTTON" name = "FullScreen" value = "full screen" onClick = "window. open (document. location, 'Big ', 'fullscreen = yes') ">
</Form>

If the full screen is not displayed on this page, you only need to replace document. location with the corresponding URL, that is, the following code:

<Form>
<Input type = BUTTON name = FullScreen value = onClick = "window. open ('url address', 'Big ', 'fullscreen = yes')">
</Form>

Second:

When running a webpage, for example, you enter http: // localhost: 8080/temp in the URL bar. jsp: Close the web page and display a blank full-screen web page by writing the following code in the body:
 
<Body onload = window. open ('','', fullscreen = 1); opener = null; window. close ()>

</Body>

Third:

In fact, it is the superposition of the above two types. Generally, this situation is also used more. When a webpage is opened directly, it enters the full screen mode. This is different from the first one, because after you click the "full screen display" button, it is a new full-screen web page, but the original normal Web page still exists, so this is better. Method: create two jsp files. The first one only runs the following code, for example, the name is demo. jsp; the second is the content you actually want to run, such as: temp. jsp:
 
Demo. jsp:

<Body onload = "window. open ('temp. jsp ',' _ blank ', 'fullscreen = 1'); opener = null; window. close ()">
 
</Body>

Temp. jsp:

<% @ Page contentType = "text/html; charset = GB2312" language = "java" %>

<Html>

<Body>

Here is my full screen content. Let's take a look at the demo. jsp we entered in the address bar. Is it disabled? OK!

</Body>

</Html>

Exit full screen

Certificate --------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
To exit full screen, I have searched a lot of information on the Internet. In general, it is difficult to achieve our desired goals, such: we can add a hyperlink <a href = "" target = "_ blank"> to open it in a new window, or apply the inverse method of the method to open full screen. However, no matter how it works, when switching from full screen to normal mode, it is always equivalent to re-opening a window. In this way, adding our original full screen mode is playing a movie, if you switch to normal mode, you have to reload it. However, there is no way. Now I will refer to the reply on the 5th floor in this post: Success. The Code is as follows:
 
<% @ Page contentType = "text/html; charset = GB2312" language = "java" %>
<Script language = "JScript">
Var o = 1;
Function goResize ()
{
Var d = document. body, e = event, m = event. srcElement; o?
New function () {moveBy (e. clientX-e.screenX, e. clientY-e. screenY); resizeBy (screen. availWidth-d.offsetWidth, screen. availHeight-d. offsetHeight); m. value = "cancel"; o = 0 }:
New function () {moveTo (0, 0); resizeTo (screen. availWidth, screen. availHeight); m. value = "full screen"; o = 1}
}
</Script>
<Input type = "button" value = "full screen" onclick = "goResize ()">

Close page

Certificate --------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
To close the page, you only need to add such a hyperlink to the page:

<A href = "javascript: self. close ()"> close the window </a>

Author: "yanghuidang"
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.