Skip to content
the poor coder

window reload in only 767 screen

Poor Man
Published
Reading time
1 min read

Window Reload in Only 767 Screen#

If you want to reload the window only when the screen size is 767px or below, you can use the following code:

Text

if(window.innerWidth <= 767) {
  location.reload();
}

This code checks the width of the window and if it is less than or equal to 767px, it reloads the page using the location.reload() method.

If you want to do this using jQuery, you can use the following code:

Text

$(window).resize(function() {
  if($(window).width() <= 767) {
    location.reload();
  }
});

This code attaches a resize event to the window and checks the width of the window on every resize. If the width is less than or equal to 767px, it reloads the page using the location.reload() method.

Another way to do this is by using media queries in CSS. You can add the following CSS code to your stylesheet:

Text

@media (max-width: 767px) {
  body:after {
    content: '';
    display: none;
    /* Reload CSS file */
    background-image: url('path/to/your/css/file.css');
  }
}

This code uses a media query to apply styles only when the screen size is 767px or below. It adds a pseudo-element to the body and sets its display to none. Then, it reloads the CSS file by changing its background-image property. This will cause the browser to reload the CSS file and apply any changes made to it.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC