JS Full screen display code three ways _javascript tips

Source: Internet
Author: User
First type:
On a regular page that has been opened, click "Full Screen" and then go to the full screen mode of the page. To: Add the following code to the <body> and </body> of a Web page:
Copy Code code as follows:

<form>
<input type= "button" name= "fullscreen" value= "full screen display" onclick= "window.open (document.location, ' big ', ' fullscreen= Yes ') ' >
</form>

If the full screen is not the page, then only need to change the document.location to the corresponding URL, that is, the following code:
Copy Code code as follows:

<form>
<input Type=button name=fullscreen value= full Screen onclick= "window.open (' URL address ', ' big ', ' Fullscreen=yes ')" >
</form>

The second type:
When running a Web page, for example, you enter directly in the URL bar: http://localhost:8080/temp.jsp, this time to close the page, and display a blank Full-screen page, the method is: in the body to write the following code:
Copy Code code as follows:

<body onload=window.open (', ', fullscreen=1); Opener=null;window.close () >
</body>

The third type:
In fact, the above two kinds of superposition, generally this situation is also used more. is when you open a Web page directly, into its full-screen mode, this situation is different from the first, because the first, when you click on the "Full Screen" button, it is a new open full screen of the page, but the original ordinary page still have, so, this is better. The method is: Create two JSP files, the first one only run the following code, such as the name demo.jsp; the second is what you actually want to run, such as: temp.jsp:

DEMO.JSP:
Copy Code code as follows:

<body onload= "window.open (' temp.jsp ', ' _blank ', ' fullscreen=1 '); Opener=null;window.close ()" >

</body>

TEMP.JSP:
Copy Code code as follows:

<%@ page contenttype= "text/html;charset=gb2312" language= "java"%>
<body>
Here is my full-screen content, and then look at the original we entered in the Address bar demo.jsp, is not closed? OK, it's done!
</body>

Exit Full Screen
--------------------------------------------------------------------------------------------------------------- -----------------------------------------------------

For the exit full-screen, I also searched a lot of information on the Internet, in general, it is difficult to achieve our desired goals, such as: We can add a hyperlink <a href= "" target= "_blank" opened in a new window, you can also apply the above open Full-screen method of the reverse method to do. However, no matter how, and finally from Full-screen to normal mode switch, it is always the equivalent of reopening a window, so, add our original Full-screen mode is putting the film, if you switch to normal mode, you have to reload, this certainly not. However, there is no way, I now refer to this post in the 5 floor of the reply: http://topic.csdn.net/t/20021028/12/1130882.html, this method, the general still go, but, it is not called this method Full-screen, The equivalent is to shift the window upward to a certain height, we can still drag the window. The code is as follows:
Copy Code code 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
--------------------------------------------------------------------------------------------------------------- -----------------------------------------------------

If you want to close the page, you only need to add a hyperlink to the page:
Copy Code code as follows:

<a href= "Javascript:self.close ()" > Close window </a>

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.