window.load函数不能使我的代码正常工作吗? [英] window.load function is not making my code work ?

查看:86
本文介绍了window.load函数不能使我的代码正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有向下发布的javascript代码.在注释窗口.load时可以正常工作,但在未注释时不能正常工作,那么如何解决呢?

Hi all ,

I have the down posted javascript code.It is working fine when the window .load is commented but does not work when it is not commented so how to solve it ?

<script runat="server">

        <WebMethod()> _
        Public Shared Function Session(ByVal key As String) As String
            Return DirectCast(HttpContext.Current.Session(key), String)
        End Function

    </script>

    <script type="text/javascript">
        var cult = "";
//        $(window).load(function() {
            function pageLoad(sender, arg) {
                PageMethods.Session("Lang", OnCallComplete, OnCallError);
            }
            function OnCallComplete(result, userContext, methodName) {

                cult = result;
                var p = $("#b");
                var pos = p.position();
                var sub = document.getElementById("men");
                sub.top = pos.top + 70;
                alert(cult);
                if (cult == "en-US") {
                    sub.left = pos.left;


                }
                if (cult == "ar-LB") {

                    sub.left = pos.left - 70;
                }


                $("#men").offset({ left: sub.left, top: sub.top });
            }

            function OnCallError(error, userContext, methodName) {

                if (error !== null) {
                    alert(error.get_message());
                }
            }

//        });

    </script>

推荐答案

(窗口).load(function(){ 函数pageLoad(sender,arg){ PageMethods.Session("Lang",OnCallComplete,OnCallError); } 函数OnCallComplete(result,userContext,methodName){ 邪教=结果; var p =
(window).load(function() { function pageLoad(sender, arg) { PageMethods.Session("Lang", OnCallComplete, OnCallError); } function OnCallComplete(result, userContext, methodName) { cult = result; var p =


(#b"); var pos = p.position(); var sub = document.getElementById("men"); sub.top =最高排名+ 70; 警惕(邪教); 如果(cult =="en-US"){ sub.left = pos.left; } 如果(cult =="ar-LB"){ sub.left = pos.left-70; }
("#b"); var pos = p.position(); var sub = document.getElementById("men"); sub.top = pos.top + 70; alert(cult); if (cult == "en-US") { sub.left = pos.left; } if (cult == "ar-LB") { sub.left = pos.left - 70; }


(#men").offset({left:sub.left,top:sub.top}); } 函数OnCallError(error,userContext,methodName){ 如果(错误!== null){ 警报(error.get_message()); } } //}); < /script >
("#men").offset({ left: sub.left, top: sub.top }); } function OnCallError(error, userContext, methodName) { if (error !== null) { alert(error.get_message()); } } // }); </script>


这篇关于window.load函数不能使我的代码正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆