【问题标题】:ASP.NET Bootstrap show modal while loading JS files at the end of body tagASP.NET Bootstrap 在 body 标记末尾加载 JS 文件时显示模式
【发布时间】:2017-11-06 16:53:16
【问题描述】:

我正在尝试使用 ASP.NET 以编程方式显示引导模式。

问题是 ScriptManager 在脚本加载之前(我在正文的末尾加载了脚本文件)。因此 ScriptManager 代码不会影响模式。

有什么方法可以绕过它而不将JS文件移动到头部?

谢谢

【问题讨论】:

  • 为什么要在body的尾部加载?
  • 为了让我的网站加载更快...
  • 你不能只用$(document).ready(function(){});吗?
  • 感谢您的建议。它确实帮助我找到了解决方案。

标签: javascript asp.net twitter-bootstrap scriptmanager


【解决方案1】:

所以,我发现了如何在没有加载 jquery 的情况下运行它。

在我添加的<head> 标签处:

<script>
    function showModal() {
        $('#myModal').modal('show');
    }
</script>

而在服务器端,我所要做的就是调用:

ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "window.onload = showModal;", true);

所以现在它甚至会在加载任何 js 文件之前调用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 2019-05-13
    • 2013-03-16
    • 2019-11-26
    • 2013-10-21
    • 2023-01-17
    相关资源
    最近更新 更多