OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

script need user interaction to run in safari

  • Thread starter Thread starter Firman Alhar
  • Start date Start date
F

Firman Alhar

Guest
I add custom code in WP Elementor something like

Code:
<script>
    document.addEventListener("DOMContentLoaded", function() {
         // some function
        }
    });
</script>

but when user open using safari, somehow it doesn't run before there's user interaction(scroll on mobile, cursor in the web). The problem is it only happens in production since it all running well in staging, event it use the same function. How can this possible? actually I'm new comer in WordPress.

I tried to change the event nor function but all doesn't works. event if I do like

Code:
<script>
    console.log('here we come');
    document.addEventListener("DOMContentLoaded", function() {
         // some function
        }
    });
</script>

the console.log run after user interact with the web

<p>I add custom code in WP Elementor something like</p>
<pre class="lang-js prettyprint-override"><code><script>
document.addEventListener("DOMContentLoaded", function() {
// some function
}
});
</script>
</code></pre>
<p>but when user open using safari, somehow it doesn't run before there's user interaction(scroll on mobile, cursor in the web). The problem is it only happens in production since it all running well in staging, event it use the same function. How can this possible?
actually I'm new comer in WordPress.</p>
<p>I tried to change the event nor function but all doesn't works. event if I do like</p>
<pre class="lang-js prettyprint-override"><code><script>
console.log('here we come');
document.addEventListener("DOMContentLoaded", function() {
// some function
}
});
</script>
</code></pre>
<p>the <code>console.log</code> run after user interact with the web</p>
 

Latest posts

Online statistics

Members online
0
Guests online
2
Total visitors
2
Ads by Eonads
Top