<a href="javascript:void(0);" onclick="getContentHtml();" >登录可见</a>
1 function getContentHtml() { 2 var username = $("#username").val(); 3 if (username == "" || username == null) { 4 alert("您还没有登陆!"); 5 window.location.href ='login.htm'; 6 } else { 7 window.location.href = 'content.htm'; 8 9 } 10 }