mozilla

Revision 453211 of Call request() only from a click handler

  • Revision slug: Mozilla/Persona/The_implementor_s_guide/Call_request()_only_from_a_click_handler
  • Revision title: Call request() only from a click handler
  • Revision id: 453211
  • Created:
  • Creator: Heisenberg_Terribly_Uncertain
  • Is current revision? Yes
  • Comment
Tags: 

Revision Content

The Persona dialog is currently implemented as a popup window. Modern web browsers typically block popups, unless they are triggered directly by a mouse click or a key press. This means that your call to {{ domxref("navigator.id.request()")}} or {{ domxref("navigator.id.get()")}} must be made directly from a click or keypress handler. If it's made in response to some other event, the popup won't be shown and the user won't be able to sign in.

For example: suppose your website has deferred sign-in, in which users can browse content, but do not have to sign in until they start editing. If you implement this by calling {{ domxref("navigator.id.request()")}} in response to a focus event on the text field, then the popup will be blocked.

You can still implement sign-in on focus as follows: on the focus event, display a dialog with a "Sign In" button, and have that button call {{ domxref("navigator.id.request()")}} in its click handler.

Revision Source

<p>The Persona dialog is currently implemented as a popup window. Modern web browsers typically <a href="http://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting" title="http://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting">block popups</a>, unless they are triggered directly by a mouse click or a key press. This means that your call to {{ domxref("navigator.id.request()")}} or {{ domxref("navigator.id.get()")}} must be made directly from a click or keypress handler. If it's made in response to some other event, the popup won't be shown and the user won't be able to sign in.</p>
<p>For example: suppose your website has deferred sign-in, in which users can browse content, but do not have to sign in until they start editing. If you implement this by calling {{ domxref("navigator.id.request()")}} in response to a focus event on the text field, then the popup will be blocked.</p>
<p>You can still implement sign-in on focus as follows: on the focus event, display a dialog with a "Sign In" button, and have that button call {{ domxref("navigator.id.request()")}} in its click handler.</p>
Revert to this revision