How to use window load event on Azure B2C pages

Jan Borowiak 55 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 Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.