【问题标题】:When I click link new Page isn't opened on the small tab当我单击链接时,新页面未在小标签上打开
【发布时间】:2014-05-13 16:09:52
【问题描述】:
 <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')    
                        });
                    });

当我clickSign in With Facebook时,我应该怎么做,新页面会在一个新的小标签上打开?我认为帽子display=popup 就足够了。但它是在同一个窗口中打开的。我也试过 &lt;a href="#" id="signinFace" target="_blank" &gt;&lt;/a&gt; ,但没有任何改变。

【问题讨论】:

  • 尝试点击链接两次,因为您在第一次点击时更改了href 属性。所以我的意思是你的代码不正确。

标签: javascript asp.net href


【解决方案1】:

试试这个代码:

 <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>

【讨论】:

  • 它有效。谢谢 当我点击时,Faceook authentication display 在新的小窗口中打开。当我输入我的电子邮件和密码并单击回车时,这个小窗口是否可能会关闭,用户会返回之前的大窗口。可能是不同的问题,如果是这样,我可以稍后再问。
【解决方案2】:

试试这个,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>

【讨论】:

    猜你喜欢
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-10
    • 2014-05-26
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    相关资源
    最近更新 更多