简体   繁体   English

提交电子邮件表格后关闭弹出窗口

[英]Close popup after email form is submitted

Can anyone shed any light on this. 任何人都可以阐明这一点。 . . . I'm trying to close an email opt-in popup upon clicking a 'submit' button. 我试图在单击“提交”按钮后关闭电子邮件的选择弹出窗口。 The pop up is using a WordPress plugin called arty popup. 弹出窗口使用一个名为arty popup的WordPress插件。 At present the popup has a close button that functions, plus there is an email address box and 'submit' button linked to a contact7 form plugin, which again works perfectly, on submitting an email address, at present the user will then have to use the pop up close button, rather than both action taking place on the one click. 目前,该弹出窗口具有一个关闭按钮,该按钮具有功能,此外还有一个电子邮件地址框和链接到contact7表单插件的“提交”按钮,再次提交电子邮件地址时,该按钮再次完美运行,此时用户将不得不使用弹出式关闭按钮,而不是一键同时执行两项操作。

apologies to post a lot of code, its only because I'm working with two plugins. 道歉以发布大量代码,这仅仅是因为我正在使用两个插件。 Any pointers would be very welcome. 任何指针都将非常受欢迎。

this is the pop up .php /* /////////////////////////////////////////////// this final section generates all the code that is displayed on the front-end of the WP Theme \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ */ function arty_popup($args = array(), $content = null) { require 'inc/popup.php'; 这是弹出的.php / * ///////////////////////////////////////// ///////最后一部分将生成WP主题的前端显示的所有代码\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ * /函数arty_popup($ args = array(),$ content = null){需要'inc / popup.php'; } }

add_action( 'wp_head', 'arty_header' );
function arty_header() { 
global $arty_settings;
$options = $arty_settings;?>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"type="text  /javascript"></script>
<script type="text/javascript">
    $(document).ready( function() {
    if (document.cookie.indexOf("arty_popup_cookie1") <= 0) {

    loadPopupBox();
    }       


$('#wrap-out, #popupBoxClose').click( function() {
    unloadPopupBox();

    var c_name  =   'arty_popup_cookie';
    var value   =   'arty_popup_cookie1';
    var exdays  =   <?php echo $options['popup_cookie_time']; ?>;

     var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : ";expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;

});

function unloadPopupBox() {
    $('#popup_box').fadeOut(200);
    $("#wrap-out").css({    
        "display": "none"  
    }); 
}

function loadPopupBox() {
    $('#popup_box').fadeIn(200);
    $("#wrap-out").css({
        "background": "#000",
        "opacity": "0.7"  
    });         
}


});

the pop up button .css 弹出按钮.css

.btn{
    color:#FFFFFF;
    width:91px;
    height:40px;
    margin-left:10px;
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size:12px;
    border:none;
    background:url(images/btn.gif) no-repeat top;
    cursor:pointer;
}

the contact7 form .php contact7表格.php

<?php
/**
** A base module for [submit]
**/

/* Shortcode handler */

add_action( 'init', 'wpcf7_add_shortcode_submit', 5 );

function wpcf7_add_shortcode_submit() {
wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' );}

function wpcf7_submit_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );

$class = wpcf7_form_controls_class( $tag->type );

$atts = array();

$atts['class'] = $tag->get_class_option( $class );
$atts['id'] = $tag->get_option( 'id', 'id', true );
$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );

$value = isset( $tag->values[0] ) ? $tag->values[0] : '';

    if ( empty( $value ) )
        $value = __( 'Send', 'wpcf7' );

$atts['type'] = 'submit';
$atts['value'] = $value;

$atts = wpcf7_format_atts( $atts );

$html = sprintf( '<input %1$s />', $atts );

return $html;}


/* Tag generator */

add_action( 'admin_init', 'wpcf7_add_tag_generator_submit', 55 );

    function wpcf7_add_tag_generator_submit() {
    if ( ! function_exists( 'wpcf7_add_tag_generator' ) )
        return;

    wpcf7_add_tag_generator( 'submit', __( 'Submit button', 'wpcf7' ),
        'wpcf7-tg-pane-submit', 'wpcf7_tg_pane_submit', array( 'nameless' => 1 ) );
}

function wpcf7_tg_pane_submit( &$contact_form ) {?>
<div id="wpcf7-tg-pane-submit" class="hidden">
<form action="">
<table>
<tr>
<td><code>id</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br />
<input type="text" name="id" class="idvalue oneline option" /></td>

<td><code>class</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br />
<input type="text" name="class" class="classvalue oneline option" /></td>
</tr>

<tr>
<td><?php echo esc_html( __( 'Label', 'wpcf7' ) ); ?> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br />
<input type="text" name="values" class="oneline" /></td>

<td></td>
</tr>
</table>

<div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'wpcf7' ) ); ?><br /><input type="text" name="submit" class="tag"readonly="readonly" onfocus="this.select()" /></div>
</form>
</div>
<?php}?>

Try changing the line 尝试换线

$('#wrap-out, #popupBoxClose').click( function() {

to

$('#wrap-out, #popupBoxClose, #popup_box [type="submit"]').click( function() {

This adds the click handler that closes the popup box to the submit button for the form, so that the popup box will close on submit. 这会将关闭弹出框的单击处理程序添加到表单的提交按钮,这样弹出框将在提交时关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM