简体   繁体   English

Janrain自定义按钮

[英]Janrain custom buttons

I'm implementing Janrain and I want to use my own buttons. 我正在实现Janrain,我想使用自己的按钮。 But when I click the button nothing happens. 但是,当我单击按钮时,什么也没有发生。 Here is my code: 这是我的代码:

<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 doesn't take those parameters, here's an example of how to use it: Triggerflow不采用这些参数,这是如何使用它的示例:

janrain.engage.signin.triggerFlow("facebook");

or 要么

janrain.engage.signin.triggerFlow("googleplus");

Each provider has a unique string/name assigned to it and that is how the social login workflow is initiated. 每个提供者都有一个唯一的字符串/名称分配,这就是启动社交登录工作流程的方式。 You simply need to bind the button onclick handler accordingly. 您只需要相应地绑定按钮onclick处理程序。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM