我有一个 ASP.net MVC 4 Web 应用程序(Visual Basic)。在 _Layout.vbhtml 共享视图上,我在代码的最底部有一小段 javascript,用于隐藏加载 div 并在所有内容加载后显示主页内容。
这是 .vbhtml 文件的一部分:
<!-- JQuery & Javascript Loading -->
@Scripts.Render("~/bundles/jquery", "~/bundles/jquerymain", "~/bundles/bootstrap", "~/bundles/lib", "~/bundles/gebo_dashboard")
@RenderSection("scripts", required:=False)
<!-- Close loading page -->
<script type="text/javascript">
$(document).ready(function () {
//* show all elements & remove preloader
alert("Hello Ready");
setTimeout('$("html").removeClass("js")', 1000);
});
</script>
</div>
</body>
这是生成的html:
<!-- JQuery & Javascript Loading -->
<script src="/Scripts/jquery-1.7.1.js"></script>
<script src="/Scripts/jquery/jquery.ui.touch-punch.js"></script>
<script src="/Scripts/jquery/jquery.ui.totop.js"></script>
<script src="/Scripts/jquery/jquery.easing.1.3.js"></script>
<script src="/Scripts/jquery/jquery.debouncedresize.js"></script>
<script src="/Scripts/jquery/jquery.cookie.js"></script>
<script src="/Scripts/jquery/jquery.qtip.js"></script>
<script src="/Scripts/jquery/jquery.colorbox.js"></script>
<script src="/Scripts/jquery/jquery.jBreadCrumb.1.1.js"></script>
<script src="/Scripts/jquery/jquery.actual.js"></script>
<script src="/Scripts/jquery/jquery.imagesloaded.js"></script>
<script src="/Scripts/jquery/jquery.wookmark.js"></script>
<script src="/Scripts/jquery/jquery.mediaTable.js"></script>
<script src="/Scripts/jquery/jquery.peity.js"></script>
<script src="/Scripts/jquery/jquery.flot.js"></script>
<script src="/Scripts/jquery/jquery.flot.pie.js"></script>
<script src="/Scripts/jquery/jquery.flot.resize.js"></script>
<script src="/Scripts/bootstrap/bootstrap.js"></script>
<script src="/Scripts/bootstrap/bootstrap.plugins.js"></script>
<script src="/Scripts/lib/jquery-mousewheel.js"></script>
<script src="/Scripts/lib/antiscroll.js"></script>
<script src="/Scripts/lib/fullcalendar.js"></script>
<script src="/Scripts/lib/ios-orientationchange-fix.js"></script>
<script src="/Scripts/lib/list.js"></script>
<script src="/Scripts/lib/list.paging.js"></script>
<script src="/Scripts/lib/prettify.js"></script>
<script src="/Scripts/lib/sticky.js"></script>
<script src="/Scripts/gebo/gebo_common.js"></script>
<script src="/Scripts/gebo/gebo_dashboard.js"></script>
<!-- Close loading page -->
<script type="text/javascript">
$(document).ready(function () {
//* show all elements & remove preloader
alert("Hello Ready");
setTimeout('$("html").removeClass("js")', 1000);
});
</script>
</div>
</body>
当我加载页面并在浏览器中查看它时,$(document).ready 函数永远不会触发,因此加载 div 可见。
我已经通过在 $(document).ready 函数之前和之后放置一个警报来测试脚本部分,并且警报完全按照我期望的方式触发。但是 $(document).ready 函数内部的警报永远不会显示,表明该函数永远不会运行。
我也尝试过使用 pageLoad() 函数,但也没有运气。
有谁知道为什么这拒绝工作?