I have a script which shows different content depending on the screen size, it looks like this:
window.onresize = function(event) {
if ((window.innerWidth > 750 && window.innerWidth < 1250)) {
//Do something
}}
The above works absolutely fine when re-sizing the browser. My question is how can i get the above to work if the user opens the page up with a window width of say 750?
I have just tested this and obviously the event isn't triggered until the browser is re-sized, this is causing the above not to work
var onResizing = function(event) {
if ((window.innerWidth > 750 && window.innerWidth < 1250)) {
//Do something
}};
window.onresize = onResizing;
window.onload = onResizing;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With