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

Why Is My Website Freezing After Clicking On An Item In The Menu? No Issue On A Mobile Device

  • Thread starter Thread starter user25680377
  • Start date Start date
U

user25680377

Guest
While testing my website on a computer, whenever I click on an item in the menu bar on my website and go to that page, then go back to the previous page, for some reason the website freezes. If I refresh the frozen page, the website runs normally. I have no problems using the website on a mobile device.

I've tried looking to see if any of the CSS or Javascript in my website would be causing this issue, but I haven't found anything.

Below is the Javascript that I'm currently using on my website. I have it set so that the content behind the mobile menu doesn't move while open and so that it will close after an item in it has been clicked.

Code:
`document.getElementById('cp_toggle03').onchange = function() {
 if (document.getElementById('cp_toggle03').checked) {
 document.body.style.overflow = "hidden";
  } else {
 document.body.style.overflow = "";
  }

}

var elements = document.getElementsByTagName('li');
var closeHamp = function() {
 document.getElementsByClassName('cp_menuicon')[0].click();
    };

 for (var i = 0; i < elements.length; i++) {
 elements[i].addEventListener('click', closeHamp, false);
    }`

Could changing or removing this Javascript help sort out the issue? If anyone has any solutions, I’d appreciate it if you’d share them with me.

My Website
<p>While testing my website on a computer, whenever I click on an item in the menu bar on my website and go to that page, then go back to the previous page, for some reason the website freezes. If I refresh the frozen page, the website runs normally. I have no problems using the website on a mobile device.</p>
<p>I've tried looking to see if any of the CSS or Javascript in my website would be causing this issue, but I haven't found anything.</p>
<p>Below is the Javascript that I'm currently using on my website. I have it set so that the content behind the mobile menu doesn't move while open and so that it will close after an item in it has been clicked.</p>
<pre><code>`document.getElementById('cp_toggle03').onchange = function() {
if (document.getElementById('cp_toggle03').checked) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "";
}

}

var elements = document.getElementsByTagName('li');
var closeHamp = function() {
document.getElementsByClassName('cp_menuicon')[0].click();
};

for (var i = 0; i < elements.length; i++) {
elements.addEventListener('click', closeHamp, false);
}`
</code></pre>
<p>Could changing or removing this Javascript help sort out the issue? If anyone has any solutions, I’d appreciate it if you’d share them with me.</p>
<p><a href="https://morikoboshi.com/" rel="nofollow noreferrer">My Website</a></p>
Continue reading...
 

Latest posts

Top