首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

window.location.href失灵

2012-10-09 
window.location.href失效function sampleQuery(txt,event){var namedocument.getElementById(txt).value

window.location.href失效

function sampleQuery(txt,event){            var name=document.getElementById(txt).value.replace(/^\s*/,"").replace(/\s*$/,"");            if(name==""||name==null)                alert("请输入昵称");            else{                window.location.href="friend.aspx?name="+escape(name)+"&sex=2";                if(window.event)                   window.event.returnValue = false;                else                    event.preventDefault();//for firefox            }        }        function KeyDown(event){            var keynum;            if(window.event) // IE            {              keynum = window.event.keyCode            }            else if(event.which) // Netscape/Firefox/Opera            {              keynum = event.which            }            if(keynum==13)                sampleQuery('TxtName',event);        }一个input 当回车的时候我会引用一个函数 那个函数中有 window.location.href 但是不跳转,当改成那段代码后就OK了
?

热点排行