Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the code for javascript to close the window

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article "javascript closed window code how to write" most people do not understand, so the editor summed up the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "javascript close window code how to write" article.

In JavaScript, the code to close the window is "window.close ()"; the close () method can close the top-level browser window specified by window, that is, close the browser window, or it can be used to close the output stream opened by the "document.open" method and display the selected data.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

What is the code for javascript to close the window?

The close () method is used to close the browser window.

Grammar

Window.close ()

Description

The method close () closes the top-level browser window specified by window. A window can close itself by calling self.close () or just calling close ().

Only windows that are opened by JavaScript code can be closed by JavaScript code. This prevents malicious scripts from terminating the user's browser.

The close () method closes an output stream opened by the document.open method and displays the selected data.

Grammar

Document.close ()

Examples are as follows:

Function closeWin () {myWindow.close ()} myWindow=window.open (',', 'width=200,height=100') myWindow.[ XSS _ clean] ("This is' myWindow'")

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report