• FireFox/Chrome不支持在前台js读后台Attributes.Add("DefaultValue")的属性


    下面的代码在IE下正常运行,在FireFox/Chrome却不行,不知道为什么?

    C#:
    this.TextBoxEmailAccount.Attributes.Add("DefaultValue", this.UserAccountTextBoxDefaultValue);

    JS:
    function FocusUserAccountBox(obj) {
        if (obj.value == obj.DefaultValue) {
            obj.value = "";
        }
        obj.style.color = "Black";
    }
    function BlurUserAccountBox(obj) {
        if (obj.value == "") {
            obj.value = obj.DefaultValue;
            obj.style.color = "Gray";
        }
    }

     
    JS中取Session的写法在FireFox/Chrome也不行!
    <script type="text/javascript">
            if (document.getElementById("MainIFrame") != null)
            {
                var url = '<% =Session["CurrentPageUrl"]%>';
                alert(url)
                var menuLevel = '<% =Session["CurrentPageMenuLevel"]%>';
                if (url != "" && url != null)
                {
                    document.getElementById("MainIFrame").src = '<% =Session["CurrentPageUrl"]%>';
                }
                if (menuLevel != "" && menuLevel != null) {
                    SetNavigator(menuLevel.replace("$$$", "&"));
                }
            }
        </script>
    下面这种JS写法在FireFox/Chrome也不行!
        function document.onkeydown() {
            if (window.event.keyCode == 13 && window.event) {
                document.getElementById("QButtonLogin").click();
            }
        }

    替代方案:
    <script type="text/javascript">
    <!--

    if(document.addEventListener){//如果是Firefox
    document.addEventListener("keypress",fireFoxHandler, true);
    }else{
    document.attachEvent("onkeypress",ieHandler);
    }

    function fireFoxHandler(evt){
    //alert("firefox");
    if(evt.keyCode==13){
       validateLogon();
    }
    }

    function ieHandler(evt){
    //alert("IE");
    if(evt.keyCode==13){
       validateLogon();
    }
    }

    //-->
    </script>

  • 相关阅读:
    记录我发现的第一个关于 Google 的 Bug
    iOS 中的 Delayed Transition
    Appstore|IPA
    地图|定位
    开发者账号
    App跳转
    国际化
    短信|彩信
    闪光灯
    Cornerstone|SVN
  • 原文地址:https://www.cnblogs.com/songsh96/p/1532677.html
Copyright © 2020-2023  润新知