javascriptfacebookiframefacebook-loginfacebook-iframe

Popping up facebook login dialog


I am writing a library to get short lived tokens from facebook.I am simply making an iframe and opening the dialog inside. If user is signed in before theres no problem but if user will be prompted first time facebook blocks iframe my code is below how can i solve this problem .

function Facebook (params){
    this.url="https://facebook.com/dialog/oauth"+params;
    this.Get=function(){
        var css="position:absolute;top:50%;left:50%;\
        transform:translate(-50%,-50%);width:500px;height:300px;z-index:9999",
        frame=document.createElement("iframe"),
        url=this.url;
        frame.setAttribute("style",css);
        return {
            pop:function(){
                document.getElementsByTagName("body")[0].appendChild(frame);
                alert(url);
                frame.setAttribute("src",url);
            }
        }
    }

}

Solution

  • I solved this by opening popup if the popup from a trusted event such as click browsers doesnt block it while trying from console anyway they will block