javascriptazureazure-ad-b2c

Error trying to add JavaScript to Azure B2C Local Signup Page


I have the following arbitrary JavaScript snippet on an HTML page stored in Azure Storage (using a screenshot to try to demonstrate, as far as I can see, that the syntax is correct): enter image description here

The page loads, it is styled correctly and everything else you would expect, proving that it is configured correctly, CORS is set etc. But the JavaScript does not run. Instead I get this error:

unified:5 Uncaught SyntaxError: Unexpected token '&'
at br (unified?local=signup&[omitted_for_brevity])
at at (unified?local=signup&[omitted_for_brevity])
at i.fn.init.append (unified?local=signup&[omitted_for_brevity])
at unified?local=signup&[omitted_for_brevity]

This is presumably being caused by this: enter image description here

Extra script caused by some kind of parse or encoding error on the original script tag.

If I load the file from storage container directly, it loads and the JavaScript fires with no problems. This tells me the HTML file is fine, so either:

I have configured everything that I can see on the User Flow:

Has anyone seen this problem before or can see what I may have done wrong in how this is configured?

Edit: Am roughly following this guide: https://learn.microsoft.com/en-us/azure/active-directory-b2c/javascript-and-page-layout?pivots=b2c-user-flow


Solution

  • You need to include the script in the head tag of the page if you're using page layout version 2.1.21 or higher for the self-asserted, or when you're using unified sign-in and sign-up page layout version 2.1.10 or higher. See: https://learn.microsoft.com/en-gb/azure/active-directory-b2c/page-layout