Basically, I've got a pretty simple setup here, I need to register an event listener, so I did that on init. This works really well in Salesforce classic. In lightning experience, the init method doesn't load. I first thought the event doesn't register, but soon I realized the problem is init method is never called. Here's the code:
<script>
function init()
{
console.log("adding event listener");
window.addEventListener("storage", handleMessage);
}
function handleMessage(e)
{
console.log("received");
console.log(e);
if(e.key === 'message')
{
window.script.clear();
window.script.load(e.newValue);
}
}
</script>
<body onload="init()">
<div id="outterId" style="position: absolute;">
<div id="innerId" style="min-width: 100vw !important;min-height: 100vh !important;"></div>
<script src="someSrc" id="someId" client-token="{!userToken}" embedded="true"></script>
</div>
</body>
Once again, this works fine in classic, but in lightning experience init doesn't load, it never logs anything into the console, but the script loads fine, and works as well as in classic.
Has anyone met this issue before? Does lightning experience have some sort of restrictions on inits of visualforce pages? How would I make it load the method/is it possible to do so?