# 我能在 head\_tag 中显示模态框吗？

**URL:** <https://meta.discourse.org/t/can-i-show-a-modal-from-head-tag/289836>\
**Category:** Development\
**Created:** [2023 年9 月 11 日 08:03 UTC](https://meta.discourse.org/t/can-i-show-a-modal-from-head-tag/289836 "2023-09-11T08:03:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

作者： ![bchoi28](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bchoi28/32/342735_2.png) [@bchoi28](https://meta.discourse.org/u/bchoi28)\
发布日期： [2024 年2 月 2 日 23:20 UTC](https://meta.discourse.org/t/can-i-show-a-modal-from-head-tag/289836/3 "2024-02-02T23:20:10Z")

</div>

Sam您好，我有一个类似的问题。

对于我们的网站，我们只使用了 `head_tag` 来进行自定义。之前，我们使用 magnific 和 jQuery 以及 iframe 来用来自不同域的可交互列表项填充模态框，但我们认为 Discourse 最近终于正式放弃了 magnific/jQuery，因为点击相同的链接没有任何反应（控制台中也没有任何内容）。

所以我在寻找下一个最佳方案。您能确认使用 DModal 是最适合我需求的方案吗？任何帮助都将非常有益！

这是我们过去用来附加 magnific 弹出触发器的一些代码。

```plaintext
   if (window.jQuery) {
        const $document = $(document)
        $document.on('click', '.otpc-magnific-trigger', function() {
            var $button = $(this)
            if ($button.hasClass('initialized')) {
                $button.magnificPopup('open')
            } else {
                $button.magnificPopup({
            type: 'inline',
            preloader: false
            })
                $button.magnificPopup('open')
                $button.addClass('initialized')
            }
            return false
        })

```

---

_[View the full topic](https://meta.discourse.org/t/can-i-show-a-modal-from-head-tag/289836)._
