Display Janrain/RPX popup only when needed

380 views Asked by At

My webpage is accessible for users without sign in, but some action requires an authentication.

I would like to show the Janrain popup window only when the user clicked on the Sign in button. My webpages usually generated dynamically with Javascript.

As far as I know, the only way to show the popup is to include an a element to the page with class="rpxnow", add the link to the rpxnow.com/js/lib/rpx.js script, and this script will add an onclick handler to my a element.

But I didn't have any a element when the page was loaded, and I don't like to waste the anonymous user's bandwidth with the unnecessary <script> tags on every page.

So my question is: how to attach the Janrain popup event trigger to a dynamically created HTML element?

1

There are 1 answers

1
JPelletier On

What's the language you are using? Just add the script tag when needed:

if ($require_authentication)
{
   echo "<script src='http://static.rpxnow.com/js/lib/rpx.js' ...";
}

if ($require_authentication)
{
   echo "<a class='rpxnow'>";
}

But you still need a element.