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>

 

posted on 2009-07-28 09:29  Sammy  阅读(1161)  评论(1编辑  收藏  举报

导航