cookies - 表单提交后设置cookie
问题描述
我正在使用 Popup Maker 和 Hubspot 表单。我将 HS 表单简码放入弹出窗口中,并尝试在表单提交时手动创建 cookie,但我的代码不起作用?谁能看到我做错了什么?我能够从 Popup Maker 文档中获得以下代码,并且我输入了自己的弹出制作者 ID 和 hubspot 表单的类。
add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
/**
* Close a popup by targeting a specific HTML element within a popup container.
*
* @since 1.0.0
*
* @return void
*/
function my_custom_popup_scripts() { ?>
<script type="text/javascript">
(function ($, document, undefined) {
jQuery('#popmake-1070').on('.hs-button.primary, input[type="submit"], input[type="button"]', function () {
jQuery.pm_cookie(
'pum-1070', // The cookie name that is checked prior to auto opening.
true, // Setting a cookie value of true.
'10 years', // Plain english time frame.
'/' // Cookie path of '/' means site wide.
);
});
}(jQuery, document))
</script><?php
解决方案
推荐阅读
- bash - Bash - 如何存储按目录创建时间戳排序的目录列表
- python - 不再能够在 python 中制作简单的数据框图
- xcode - SwiftUI 菜单选择器导航栏仅显示图标
- vue.js - 无法解压缩工件 - 需要回答 shell 问题
- angular-cli - Angular CLI 是如何落后的?
- javascript - 如何检查 React JS 中的数组包含什么?
- reactjs - 无法读取未定义的属性“_targets”(传单+打字稿)
- asp.net - 如何在 Vs2019 中使用 Shift 和 F2
- delphi - 使用 Delphi 以编程方式计算 FastReport 中的所有页面
- sql-server - 如何使用 jest 模拟 SQL Server 数据库连接