如何解决如何通过代码触发Elementor Popup
这里有人使用Elementor吗?您如何通过代码触发弹出窗口?例如。
function popup_call(){
...
if(....){
//trigger the popup here...
}
}
解决方法
这个问题已经回答:
XML GENERATE
https://github.com/elementor/elementor/issues/7077#issuecomment-595570337
或尝试将弹出窗口绑定到按钮,用CSS隐藏该按钮
// accessible on window.elementorProFrontend
elementorProFrontend.modules.popup.showPopup( { id: 123 } );
并在js中使用click(jquery)
.yourbtn {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0);
border: 0;
}
https://github.com/elementor/elementor/issues/7077#issuecomment-595570337
如果第二种方法对您有帮助,请不要忘记在屏幕阅读器中隐藏按钮 aria-hidden =“ true”和tabindex =“-1”
,Elementor的弹出窗口需要注册和触发。 This主题可能会对您有所帮助。
使用wp_footer钩子注册弹出窗口。
add_action( 'wp_footer','your_popup_function',10,5);
function your_popup_function(){
if(..assuming your condition is true..){
$popup_id = '2409'; //your Popup ID.
ElementorPro\Modules\Popup\Module::add_popup_to_location( $popup_id ); //insert the popup to the current page
?><script>
jQuery( document ).ready( function() { //wait for the page to load
/* You can do more here,this will just show the popup on refresh of page,but hey this is JQuery so you can do more things here depending on your condition to trigger the popup */
jQuery( window ).on( 'elementor/frontend/init',function() { //wait for elementor to load
elementorFrontend.on( 'components:init',function() { //wait for elementor pro to load
elementorFrontend.documentsManager.documents[<?php echo $popup_id ;?>].showModal(); //show the popup
} );
} );
} );
</script>;
<?php
}
return; //return nothing by default and do not show the popup.
}
阅读评论以获得更多说明。
,我不知道您为什么需要代码,如果您需要单击打开一个弹出窗口,而没有在浏览器的底部显示url(像标记一样工作),请尝试“自定义类”。 / p>
,对我来说,它在 Wordpress 5.7.2 和 elementor pro 3.2.1 上是这样工作的
function popup_call(){
...
if(....){
//trigger the popup here...
echo"<script> window.onload = function() {
elementorProFrontend.modules.popup.showPopup( {id:13000},event); }
</script>";
}
}
只需设置 ID
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。