javascript facetwp为海狸构建器修改了“如何为页面保留方面选择”代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript facetwp为海狸构建器修改了“如何为页面保留方面选择”代码相关的知识,希望对你有一定的参考价值。

<script>
	(function($) {
		$(function() {

			/*
			After FacetWP reloads, store any updates into a cookie
			*/

			$(document).on('facetwp-loaded', function() {
        			if ( typeof FLBuilder == 'undefined' ) {
					var date = new Date();
					var facets = window.location.search;
					date.setTime(date.getTime()+(24*60*60*1000));
					document.cookie = "facetdata="+facets+"; expires="+date.toGMTString()+"; path=/";
        			}
			});

			/*
			When FacetWP first initializes, look for the "facetdata" cookie
			If it exists, set window.location.search= facetdata
			*/

			$(document).on('facetwp-refresh', function() {
				if (! FWP.loaded && typeof FLBuilder == 'undefined' ) {
					var facets = window.location.search;
					var facetdata = readCookie('facetdata');
					if (null != facetdata && '' != facetdata && facets != facetdata) {
						document.cookie = 'facetdata=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';
						window.location.search = facetdata;
					}
				}
			});

			/*
			Cookie handler
			*/
			function readCookie(name) {
				var nameEQ = name + "=";
				var ca = document.cookie.split(';');
				for(var i=0;i < ca.length;i++) {
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1,c.length);
					if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
				}
				return null;
			}
		});
	})(jQuery);
	</script>

以上是关于javascript facetwp为海狸构建器修改了“如何为页面保留方面选择”代码的主要内容,如果未能解决你的问题,请参考以下文章

php 布局构建器中的facetwp注释

php facetwp woocommerce布局构建器

php facetwp布局构建器没有结果输出

css facetwp布局构建器媒体查询

将文本拆分为句子

php 布局构建器中的facetwp短代码