[英]Janrain custom buttons
我正在實現Janrain,我想使用自己的按鈕。 但是,當我單擊按鈕時,什么也沒有發生。 這是我的代碼:
<head>
<script type="text/javascript">
(function() {
if (typeof window.janrain !== 'object') window.janrain = {};
if (typeof window.janrain.settings !== 'object') window.janrain.settings = {};
janrain.settings.tokenUrl = 'janrain/rpx-token-url.php';
janrain.settings.appId = 'my app id here';
janrain.settings.appUrl = 'https://loanerr.rpxnow.com';
janrain.settings.providers = [
'googleplus',
'facebook',
'linkedin'];
function isReady() { janrain.ready = true; };
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", isReady, false);
} else {
window.attachEvent('onload', isReady);
}
var e = document.createElement('script');
e.type = 'text/javascript';
e.id = 'janrainAuthWidget';
if (document.location.protocol === 'https:') {
e.src = 'https://rpxnow.com/js/lib/coacharabia/engage.js';
} else {
e.src = 'http://widget-cdn.rpxnow.com/js/lib/coacharabia/engage.js';
}
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(e, s);
})();
</script>
</head>
<body>
<div id="widgetContainer">
<div id="facebook" class="idpButton social"><span class="fa fa-facebook fa-lg"></span></div>
<div id="google" class="idpButton social"><span class="fa fa-google-plus fa-lg"></span></div>
<div id="linkedin" class="idpButton social"><span class="fa fa-linkedin fa-lg"></span></div>
</div>
<script>
function janrainWidgetOnload() {
// First, we construct an object to house all of our sign-in buttons
var buttons = document.getElementsByClassName('social');
// Then, we cycle through each button and attach each to a provider
for (var b = 0; b < buttons.length; b++) {
var button = buttons[b];
janrain.engage.signin.triggerFlow(button, button.id);
}
}
</script>
</body>
Triggerflow不采用這些參數,這是如何使用它的示例:
janrain.engage.signin.triggerFlow("facebook");
要么
janrain.engage.signin.triggerFlow("googleplus");
每個提供者都有一個唯一的字符串/名稱分配,這就是啟動社交登錄工作流程的方式。 您只需要相應地綁定按鈕onclick處理程序。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.