如何使用 Jquery 或 Jquery 插件生成像 Google 地图中那样的弹出窗口?

发布于 2024-08-14 16:33:03 字数 102 浏览 2 评论 0原文

当您使用 Google 地图时,单击地图上的标记,然后会弹出一个窗口。您甚至可以输入您的手机号码并接收来自 Google 的短信。如何使用 Jquery 或 Jquery 插件生成弹出窗口?

When you use Google Maps, you click a marker on a map, then a window will pop up. You can even enter your mobile phone number and receives a sms from Google. How to generate that popup window using Jquery or Jquery plugin?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏雨凉 2024-08-21 16:33:04

我假设 Google 地图只是您想要的效果的一个示例,而不是您的项目基础:

这实际上只不过是显示特定的 div,然后隐藏它。

$("a.popup1").click(function(e){
  e.preventDefault();
  $("div.popup1").toggle();
});

-

<a class="popup1" href="enable-javascript.html">Show Popup</a>
<div class="popup1"><p>This is where your data goes.</p></div>

-

如果 Google 地图实际上是您的项目基础,我建议您查看 jMaps,一个 jQuery谷歌地图插件。添加标记和 pointHTML(您所说的那些窗口)的示例可以在这里找到:http://github.com/digit...Google.Markers.AddMarker.html

I'm assuming Google Maps is merely an example of the effect you want, and not your project-base:

This is really nothing more than showing a specific div, and later hiding it.

$("a.popup1").click(function(e){
  e.preventDefault();
  $("div.popup1").toggle();
});

-

<a class="popup1" href="enable-javascript.html">Show Popup</a>
<div class="popup1"><p>This is where your data goes.</p></div>

-

If Google Maps is actually your project-base, I would suggest checking out jMaps, a jQuery Google Maps Plugin. Examples of adding Markers and pointHTML (those windows you speak of) can be found here: http://github.com/digit...Google.Markers.AddMarker.html

Smile简单爱 2024-08-21 16:33:04

有各种各样的变体,但基本上您要做的是:

  1. 首先,向文档(或某些容器元素,取决于您的站点的外观)添加一个“div”,
  2. 运行 AJAX 事务来获取你的小弹出窗口的内容(如果它不在页面上隐藏的某个地方)
  3. 给div适当的CSS你想要类属性以你想要的方式设置它的样式(重要的是,使它可见:-)

在你的弹出窗口中框应包含一个按钮或其他一些控件以允许将其删除。您可以使用 jQuery offset() 函数查找被单击的内容的页面位置,然后可以使用位置信息(左上角)来定位浮动元素。您的浮动元素可能应该使用绝对定位进行定位,并给出一个大于周围内容的“z-index”值。

具体如何做到这一点实际上很大程度上取决于您的网站的外观、其他内容的排列和定位方式以及您如何获取/合成弹出窗口的内容。

There are all sorts of variations, but basically what you'll do is:

  1. to start off, add a "div" to the document (or to some container element, depending on what your site looks like)
  2. run an AJAX transaction to fetch the content for your little popup (if it's not there on the page hidden somewhere already)
  3. give the div appropriate CSS u want class attributes to style it the way you want (importantly, to make it visible :-)

Among the things your pop-up box should contain is a button or some other control to allow it to be removed. You can use the jQuery offset() function to find the page position of something that was clicked on, and then the position information (top left corner) can be used to position your floating element. Your floating element should probably be positioned with absolute positioning and given a "z-index" value that's bigger than the surrounding content.

Exactly how you do this really depends a lot on what your site looks like, how the other content is arranged and positioned, and how you get/synthesize the content of the popups.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文