How to use window load event on Azure B2C pages

Jan Borowiak 50 Reputation points
2023-03-20T14:38:55.24+00:00

I have the Custom UI for Azure B2C. I would like to do some actions on window load event https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event

I tried to do it in different ways, e.g.

window.onload = function() {
   console.log('Window loaded');
};
window.addEventListener('load', function() {
    console.log('Window loaded');
 });

However, none of them works.

Is it possible to utilize the window load level on Azure B2C pages?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,569 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. 2023-03-22T14:35:13.8766667+00:00

    Hello @Jan Borowiak , the event handlers not being ran may be caused by B2C UI overriding them to ensure proper function. As a workaround, try using $(document ).ready()

    $( document ).ready(function() {
        console.log( "ready!" );
    });
    

    Let us know if you need additional assistance. If the answer was helpful, please accept it and rate it so that others facing similar issues can more easily find a solution.