我在我管理的网站上有一个页脚横幅,当我点击隐藏或隐藏时,它会调用以下javascript来隐藏或隐藏横幅:
/**
* Main JS File
*
* @author Your Inspiration Themes
* @package YITH Footer Banner
* @version 1.0.3
*/
jQuery(document).ready(function($) {
if($.cookie(templateDir) == '1') {
$(".fbanner").hide();
}
$("#showhidefbanner a").on('click',function(event){
event.preventDefault();
$('.fbanner').hide();
});
$("#showhideforever").on('click',function(event){
event.preventDefault();
$(".fbanner").hide();
$.cookie(templateDir, '1',{ expires: 365, path: '/' });
});
});
直到这里一切都好。 问题在于,当有人向表格发送横幅广告不断出现时。所以我想把这个javascript称为永远不再显示这个横幅。这是我的PHP代码:
<?php
/**
* Footer Banner page
*
* @author Your Inspiration Themes
* @package YITH Footer Banner
* @version 1.0.0
*/
;?>
<!-- YITH-FOOTER-BANNER -->
<div class="fbanner">
<div id="fbannercont" class="group">
<div id="fbannerlogo">
<?php if (get_option('yith_fbanner_link')):?><a href="<?php echo get_option('yith_fbanner_link');?>" title="<?php echo get_option('yith_fbanner_message');?>"><?php endif;?>
<img src="<?php echo get_option('yith_fbanner_image');?>" alt="<?php echo get_option('yith_fbanner_message');?>"/>
<?php if (get_option('yith_fbanner_link')):?></a><?php endif;?>
</div>
<ul id="fbannermess">
<li>
<h3>
<?php if (get_option('yith_fbanner_link')):?><a href="<?php echo get_option('yith_fbanner_link');?>" title="<?php echo get_option('yith_fbanner_message');?>"><?php endif;?>
<?php echo get_option('yith_fbanner_message');?>
<?php if (get_option('yith_fbanner_link')):?></a><?php endif;?>
</h3>
</li>
<li>
<p>
<?php if (get_option('yith_fbanner_link')):?><a href="<?php echo get_option('yith_fbanner_link');?>" title="<?php echo get_option('yith_fbanner_message');?>"><?php endif;?>
<?php echo get_option('yith_fbanner_sub_message');?>
<?php if (get_option('yith_fbanner_link')):?></a><?php endif;?>
</p>
</li>
</ul>
<div id="fbannernews">
<?php if ( get_option('yith_fbanner_enable_newsletter_form') == true ): ?>
<form method="<?php echo get_option('yith_fbanner_newsletter_method') ?>" action="<?php echo _e (get_option('yith_fbanner_newsletter_action') ,'yit');?>" class="fbannernewsletter">
<input type="hidden" name="form_id" value="147265" />
<input type="hidden" name="encoding" value="" />
<fieldset>
<?php if(get_option('yith_fbanner_newsletter_name_label')){?>
<ul class="newsfields">
<li class="newstop">
<input type="text" name="<?php echo get_option('yith_fbanner_newsletter_name_name') ?>" id="<?php echo get_option('yith_fbanner_newsletter_name_name') ?>" class="name-field text-field" placeholder="<?php echo get_option('yith_fbanner_newsletter_name_label') ?>" />
</li>
<li class="newsbottom">
<input type="text" name="<?php echo get_option('yith_fbanner_newsletter_email_name') ?>" id="<?php echo get_option('yith_fbanner_newsletter_email_name') ?>" class="email-field text-field" placeholder="<?php echo get_option('yith_fbanner_newsletter_email_label') ?>" />
</li>
</ul>
<input type="submit" value="<?php echo get_option('yith_fbanner_newsletter_submit_label') ?>" class="submit-field newssubmit" />
<?php } else { ?>
<input type="text" name="<?php echo get_option('yith_fbanner_newsletter_email_name') ?>" id="<?php echo get_option('yith_fbanner_newsletter_email_name') ?>" class="email-field text-field" placeholder="<?php echo get_option('yith_fbanner_newsletter_email_label') ?>" />
<input type="submit" value="<?php echo get_option('yith_fbanner_newsletter_submit_label') ?>" class="submit-field" />
<?php };?>
<?php $hiddenfields = get_option('yith_fbanner_newsletter_hidden_fields');
if ($hiddenfields) :
$result = explode('&',$hiddenfields);
foreach ($result as $hivalue ) :
$formvalue = explode('=',$hivalue);?>
<input type="hidden" id="<?php echo $formvalue[0] ?>" name="<?php echo $formvalue[0] ?>" value="<?php echo $formvalue[1] ?>" />
<?php endforeach; endif;?>
</fieldset>
</form>
<?php endif; ?>
</div>
</div><!-- fbannercont -->
<ul class="hiderzone">
<li>
<div id="showhideforever">
<a href="#" title="<?php _e( get_option('yith_fbanner_hide_forever_message') ,'yit');?>">
<?php echo _e( get_option('yith_fbanner_hide_forever_message') ,'yit');?>
</a>
</div>
</li>
<li>
<div id="showhidefbanner">
<a href="#" title="<?php _e( get_option('yith_fbanner_hide_message') ,'yit');?>">
<?php _e( get_option('yith_fbanner_hide_message') ,'yit');?>
</a>
</div>
</li>
</ul>
</div><!-- fbanner -->
<!-- YITH-FOOTER-BANNER -->
有谁知道如何解决这个问题? 提前致谢
答案 0 :(得分:1)
尝试创建一个js函数并在发送表单后调用该函数:
<script>
function showHideBannerFix() {
$(".fbanner").hide();
$.cookie(templateDir, '1',{ expires: 365, path: '/' });
}
</script>
在你的php中,表单被提交给:
echo '<script>showHideBannerFix();</script>';
我没有测试过,但我认为是对的。