js调用php变量

1

function Check()// 验证表单数据有效性的函数
{ 
    var name= '<?php echo $user;?>';
    if(name==""){
           window.alert('请先登录!');     
        return false;
        }
        return true;
}

Done!