Custom Script in New Universal Login Page: "Forgot password?" Does Not Work as Expected

Overview

This article explains why a script that was working on the New Universal Login custom Template suddenly breaks due to a change in the page's HTML structure (login widget).

  • For example, a script replaces the "href" attribute of the "a" element to overwrite the "Forgot password?" link.

Applies To

  • Custom Scripts
  • New Universal Login Page

Cause

A common cause is a fragile CSS Selector. For example, the below selector can be broken with a small change in the HTML structure.

document.querySelector("form div:nth-child(4) div a")

As an example, in one past case, the element type was changed from "a" to "button". Even if the CSS selector is resilient, it could break.

Solution

The HTML structure of the login page is considered to be "implementation details" that can be subject to change.
It is not recommended that the login widget be updated with scripts.

Removing the default link with Management API and inserting a new link to the template (without using a script) would be the most stable approach. 

Recommended content

No recommended content found...