Title: Close window link
Last modified: August 22, 2016

---

# Close window link

 *  Resolved [aguerram](https://wordpress.org/support/users/aguerram/)
 * (@aguerram)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/close-window-link/)
 * Hi there 🙂
 * Is there a way to close the pop window by clicking on a link (e.g. Close this
   window) ?
 * This would be really helpful
 * [https://wordpress.org/plugins/alligator-menu-popup/](https://wordpress.org/plugins/alligator-menu-popup/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [cubecolour](https://wordpress.org/support/users/numeeja/)
 * (@numeeja)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/close-window-link/#post-5776698)
 * This needs to be addresed in the page that is popped up rather than the page 
   that contains the link that causes the page to pop up.
 * I have created a plugin to add a “Close this Window” link to a page that has 
   been popped up from alligator popup or alligator menu popup:
 *     ```
       <?php
       /*
       Plugin Name: Alligator Popup Close Button
       Description: Shortcode to create a link to close a page popped up via alligator popup or alligator menu popup.
       Author: Michael Atkins
       Version: 1.0.0 beta
       Author URI: http://cubecolour.co.uk/
       License: GPLv3
   
         Copyright 2015 cubecolour
   
         Licenced under the GNU GPL:
   
         This program is free software; you can redistribute it and/or modify
         it under the terms of the GNU General Public License as published by
         the Free Software Foundation; either version 2 of the License, or
         (at your option) any later version.
   
         This program is distributed in the hope that it will be useful,
         but WITHOUT ANY WARRANTY; without even the implied warranty of
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         GNU General Public License for more details.
   
         You should have received a copy of the GNU General Public License
         along with this program; if not, write to the Free Software
         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       */
   
       // ==============================================
       //  Prevent Direct Access of this file
       // ==============================================
   
       if ( ! defined( 'ABSPATH' ) ) exit; // Exit if this file is accessed directly
   
       // ==============================================
       // shortcode to add a 'Close this window' link
       // usage: [closepopup]
       // ==============================================
   
       function cc_close_popup_shortcode( $atts, $content = null ) {
   
       	$closelink  = '<script language="javascript">';
       	$closelink .= 'function CloseWindow() {';
       	$closelink .= 'window.close();';
       	$closelink .= '}';
       	$closelink .= '</script>';
       	$closelink .= '<a class="popup-close-button" href="javascript:CloseWindow()">Close This Window</a>';
   
       	echo $closelink;
       }
   
       add_shortcode( 'closepopup', 'cc_close_popup_shortcode' );
       ```
   
 * To use this, add a `[closepopup]` shortcode where you want the link to appear
   on the page you have created as the popup.
 * This can be styled as a static button by adding some CSS rules to your child 
   theme’s stylesheet – eg:
 *     ```
       a.popup-close-button  {
       	background: #444;
       	border: 1px solid #fff;
       	border-radius: 30px;
       	color: #fff;
       	display: block;
       	font-size: 16px;
       	line-height: 1;
       	padding: 10px;
       	position: fixed;
       	bottom: 20px;
       	right: 50%;
       	width: 200px;
       	margin-right: -100px;
       	text-align: center;
       }
   
       a.popup-close-button:hover,
       a.popup-close-button:active {
       	background: #f660ab;
       	color: #fff;
       }
       ```
   
 *  [ryanllogan](https://wordpress.org/support/users/ryanllogan/)
 * (@ryanllogan)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/close-window-link/#post-5777063)
 * Hello. Just started using the plugin. Very cool. However, I don’t understand 
   how the plugin to the close the window is any different than the visitor clicking
   on the ‘X’.
 * On the page that pops up, I have a button that links to an underlying page. I
   didn’t have ‘open in a new window’ checked, so the underlying page opened in 
   the same popup window. I got around this by enabling ‘open in a new window’.
 * Now, as the other posted noted…the popup window stays behind. It would be amazing
   if the popup windows closed automatically when following a link that takes you
   outside of the popup page.
 *  Plugin Author [cubecolour](https://wordpress.org/support/users/numeeja/)
 * (@numeeja)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/close-window-link/#post-5777064)
 * You can also click the window’s × button, but the question asked was how to add
   a link. This might be useful to make a ‘dismiss’ button or the solution could
   be tweaked to provide a link at the end of a large amount of text to dismiss 
   the window after the text has been read.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Close window link’ is closed to new replies.

 * ![](https://ps.w.org/alligator-menu-popup/assets/icon-256x256.png?rev=1485174)
 * [Alligator Menu Popup](https://wordpress.org/plugins/alligator-menu-popup/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/alligator-menu-popup/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/alligator-menu-popup/)
 * [Active Topics](https://wordpress.org/support/plugin/alligator-menu-popup/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/alligator-menu-popup/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/alligator-menu-popup/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [cubecolour](https://wordpress.org/support/users/numeeja/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/close-window-link/#post-5777064)
 * Status: resolved