By default functionalities like running custom scripts and calling APIs are disabled when previewing contents in your browser.
This is a security rule that is applied to prevent intentional and unintentional harmful scripts from running in your browser.
How to disable this feature temporarily while previewing a content
Open the preview of the content in your browser, and press F12 on your keyboard.
The devTools window will open, and you can navigate over to the Console tab to view the error.
The error will only show up in the console when the custom action happens, so interact with your content until you see the error message popup.
Once the error shows right-click at the end of it on the getContentId() part, and select store as global variable.
Once you stored the script as a global variable you need to run it in the console.
Type “temp1();” and hit enter on your keyboard.
After running the script you can refresh your browser window with F5 on your keyboard or with the refresh button, and all the custom functionalities should work in your content.
You only have to go through this process once for every content.