how to open a popup on hover event with clickable contant(如何使用可点击的内容打开悬停事件的弹出窗口)
问题描述
我目前正在使用传单.
我正在尝试创建一个带有可点击内容的弹出窗口.
and i am trying to create a popup with with clickable content.
现在我找到了如何将点击事件上的弹出窗口与内容绑定:
now i found how i can bind popups on click event with content:
marker.on('click', function(e){
marker.bindPopup("<div />").openPopup();
}
我发现了如何在悬停时创建弹出窗口:
and i found out how to create the popup on hover:
marker.on('mouseover', function(e){
e.target.bindPopup("<div />").openPopup();
}});
marker.on('mouseout', function(e){
e.target.closePopup();
}});
现在我似乎不能做的是让弹出窗口保持打开状态,以便用户点击弹出窗口内的链接.我将不胜感激.
now what i cant seem to do is make the popup stay open in order for the user to click on links inside the popup. i would appreciate any help.
推荐答案
一种方法是这样 http://jsfiddle.net/cxZRM/98/基本上它是在您的设置中添加一个计时器,并且您仅在经过任意长时间后才关闭弹出窗口,以便给用户一些时间在您的 div 上进行交互.
one approach is this http://jsfiddle.net/cxZRM/98/ basically it's adding a timer to your setup and you only close the popup after an arbitrarily long time has passed so as to give the user some time to interact on your div.
marker.on('mouseover', function(e){
e.target.bindPopup("dsdsdsdsd").openPopup();
start = new Date().getTime();
});
marker.on('mouseout', function(e){
var end = new Date().getTime();
var time = end - start;
console.log('Execution time: ' + time);
if(time > 700){
e.target.closePopup();
}
});
更好的方法是使用 http://jsfiddle.net/AMsK9/确定您的鼠标位置并在鼠标仍在弹出窗口周围的区域内时保持弹出窗口打开.
a better approach would be to use http://jsfiddle.net/AMsK9/ to determine your mouse position and keep the popup open while the mouse is still within an area around the popup.
这篇关于如何使用可点击的内容打开悬停事件的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用可点击的内容打开悬停事件的弹出窗口


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01