I have a specific code that comes from Revolution Slider. Right now, if you click on this, it will popup like I need. But what I need it to do is auto popup once someone comes to the site. Essentially turning this into an auto click. How could I change this code in order to make it happen? You can see the code below.
You can also see the code working here: https://ae32d5d93a.nxcli.net/
<button id="clickMe" onclick="document.dispatchEvent(new Event('RS_OPENMODAL_slider-2')); return false">Auto Popup</button>
EDIT:
So I added it into a Magento 2 CMS Page and I am calling out the .js esstentionally. That part is working, as you can see the link grabs the javascript you sent me.
{{block class="MagentoFrameworkViewElementTemplate" template="Magento_Theme::popup.phtml"}}
2
Answers
You can do a couple of things to achieve this.
onclick
function in the bodyonload
event. For example, something like this should work:window.onload
function. See below for an example:HTML:
Javascript:
HTML
CSS
to hide the button
Javascript:
to run the code when the page loads