我有一个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()函数也没有运气。
有谁知道为什么拒绝工作?
答案 0 :(得分:1)