当我点击链接时,小页面上没有打开新页面

时间:2014-04-02 11:44:51

标签: javascript asp.net href

 <a href="#" id="signinFace" >Sign in With Facebook</a>
                <script type="text/javascript">
                    $(document).ready(function () {
                      $("#signinFace").click(function () {
                            $(this).attr('href', 'https://www.facebook.com/dialog/oauth/?client_id=' +
                            '5649219384156&' +
                            'redirect_uri=http%3A%2F%2Flocalhost%3A4151%2FMainPage.aspx&' +
                            'response_type=code&' +
                            'scope=email,user_birthday,user_location&' +
                            'display=popup')    
                        });
                    });

当我click Sign in With Facebook时,我应该怎样做,新页面会在新的小标签上打开?我认为帽子display=popup就足够了。但它在同一个窗口打开。我也试过了<a href="#" id="signinFace" target="_blank" ></a>,但没有改变。

2 个答案:

答案 0 :(得分:1)

试试这个,window.open无法在新窗口中打开,因此请使用target = "_blank"

<a href="#" id="signinFace" >Sign in With Facebook</a>
    <script type="text/javascript">
    $(document).ready(function(){
    $(".signinFace").click(function(){
    $(this).target = "_blank";
    window.location= 'URL_HERE'; 
    return false;     
    });
    });
    </script>

答案 1 :(得分:0)

试试这段代码:

 <a href="#" id="signinFace" >Sign in With Facebook</a>
                <script type="text/javascript">
                    $(document).ready(function () {
                      $("#signinFace").click(function (e) {
                            event.preventDefault();
window.open("Your URL HERE",windowName,'height=200,width=150');
                        });
                    });
</script>