Hongmu Notes
Home Language Notes JavaScript close this page after three seconds
Language Notes JavaScript

JavaScript close this page after three seconds

JavaScript close this page after three seconds

You can use JavaScript in setTimeout() Function to achieve the effect of automatic page closing. Here is a sample code:

setTimeout(function() {
    window.close();
}, 3000);

In this code,setTimeout() The function will call an anonymous function after 3 seconds, and the anonymous function will call window.close() Method closes the current page. So, after executing the above code, the page will automatically close after 3 seconds.

It should be noted that this code can only be used in the same source page of the opened window or tab. Otherwise, an error will be reported.

 
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

js move the mouse up to modify the style attribute

js move the mouse up to modify the style attribute Language Notes JavaScript

When the mouse hovers over the element, the color changes to red; when the mouse leaves the element, the color changes to black. To retrieve an element by its ID: `document.getElementById()`; Event handler for mouse hover: `onmouseover`; Event handler for mouse leave: `onmouseout`.<!DOCTYPE html><html lang= "en">...
👁 130

Recommended reading

(PC+WAP) Environmental New Materials Technology – pbootCMS Website Template Download (0066)

(PC+WAP) Environmental New Materials Technology – pbootCMS Website Template Download (0066) Practical Collection pbootcms Template

A PbootCMS website template designed for environmental protection new materials technology companies, supporting both PC and mobile access. It features a modern, minimalist design that highlights technological innovation and environmental sustainability. This template is ideal for new materials enterprises seeking to establish an industry-leading brand image; it effectively showcases innovative eco-friendly materials, R&D achievements, and corporate strength. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: ad...
👁 50
(Adaptive mobile version) Certificate query system website template 0998

(Adaptive mobile version) Certificate query system website template 0998 Practical Collection pbootcms Template

A Certificate Verification System – PbootCMS website template, compatible with both PC and WAP devices. Featuring a clean and user-friendly design, it provides users with convenient certificate authenticity verification and information validation services. Ideal for educational institutions, industry associations, or enterprises looking to build an official certificate inquiry platform. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 57
Responsive shelving and container website template – 0791

Responsive shelving and container website template – 0791 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the shelving and container storage industry. Its professional and practical design enables effective presentation of shelving products, container storage solutions, warehousing solutions, and project case studies. This template helps warehousing equipment manufacturers showcase their products online and attract retail and logistics clients. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YououCMS...
👁 57
PHP batch replaces file names in specified folders

PHP batch replaces file names in specified folders Language Notes PHP

The following is a PHP function that can batch rename file names in a specified folder: 🔒 Hidden content: You can view the function after logging in batchRenameFiles($dir, $search, $replace) { $files = scandir($dir); // Get all files in the directory foreach ($files…
👁 235
(PC + WAP) Eco-friendly & Energy-Saving Research-Based PbootCMS Website Template – Download Blue Eco-Friendly Corporate Website Source Code (0067)

(PC + WAP) Eco-friendly & Energy-Saving Research-Based PbootCMS Website Template – Download Blue Eco-Friendly Corporate Website Source Code (0067) Practical Collection pbootcms Template

This PbootCMS template features a blue color scheme and is specifically designed for environmental protection and energy-saving organizations as well as research institutions; it supports both PC and WAP devices. The page design is professional and meticulous, making it ideal for showcasing environmental technologies, research achievements, and project cases. It helps environmental research institutes or energy-saving enterprises establish an authoritative online brand image and seize more collaboration opportunities. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin...
👁 44
(Adaptive mobile version) Traditional Chinese Medicine Museum Traditional Chinese Medicine Website Template 0999

(Adaptive mobile version) Traditional Chinese Medicine Museum Traditional Chinese Medicine Website Template 0999 Practical Collection pbootcms Template

A Chinese medicine shop and traditional Chinese medicine PbootCMS website template, supporting PC and WAP. The design style is classical and traditional, suitable for traditional Chinese medicine halls and traditional Chinese medicine stores to display services, physician teams and traditional Chinese medicine products. It helps traditional Chinese medicine institutions establish a professional image online and attract patients. Template display Installation instructions Website backend:/admin.php Account: admin Password: admin Unzip password: www.4s5.cn Related articles…
👁 39