Janrain 自定义按钮
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");
每个提供商都有一个唯一的 string/name 分配给它,这就是社交登录工作流程的启动方式。您只需要相应地绑定按钮的 onclick 处理程序。
希望对您有所帮助。
我正在实施 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");
每个提供商都有一个唯一的 string/name 分配给它,这就是社交登录工作流程的启动方式。您只需要相应地绑定按钮的 onclick 处理程序。
希望对您有所帮助。