JavaScript页面回发失败

JavaScript failing on page postback

本文关键字:失败 JavaScript      更新时间:2023-09-26

我已经得到了这个脚本给效果的按钮,我有,它失败后页面被张贴回来,我也把代码在pageLoad方法,但它仍然不起作用。任何想法,我可以去使这个脚本运行一旦页面加载。

$(document).ready(function () {
            /*preloader for image loading bar*/
            jQuery(function ($) {
                function preLoad() {
                    //alert("script running");
                    $("#divQuestionMatrix").addClass("hidden");
                }
                function loaded() {
                    $("#divQuestionMatrix").removeClass("hidden");
                    $('div#preLoader').css({ display: 'none' }).remove();
                }
                preLoad();
                window.onload = loaded;
            });
            /* End of preloader*/

            $("#btnPrevious").click(function (e) {
                $("#navigation").val("previous");
            }
            );
            $("#btnNext").click(function (e) {
                $("#navigation").val("next");
            }
            );
            /* $(".qmatrix").click(function () {
            //get id of button
            alert($(this).attr('id'));
            $("#navigation").val($(this).attr('id'));
            }
            );*/
            $(".qmatrix").hover(function (e) {
                //get id of button
                //alert($(this).attr('id'));
                //get src of image before hover
                var origimage = $(this).attr('src');
                // alert(origimage);
                //$(this).attr({ src: 'images/questionMatrix/100' + $(this).attr('id') + '.png' });
                $(this).stop().animate({ "opacity": "0.1" }, "fast")
            },
            function () {
                // $(this).attr({ src: '' + origimage.toString() + '' });
                $(this).stop().animate({ "opacity": "1" }, "fast");
            }
    );

一旦页面加载完成,document.ready事件将被触发。

在ready事件的处理程序中,然后使用ready事件快捷方式(将函数直接传递给全局jQuery函数(与全局$函数相同))为ready事件添加另一个处理程序函数。

在这个第二就绪处理程序中,你然后试图将加载的函数分配给window.onload,它在此时已经触发。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

把这个最新的Jquery库放在你的document.ready()函数上面,并尝试运行你的程序。