javascript window.onresize on page load
javascript, window
Solution
var onResizing = function(event) {
if ((window.innerWidth > 750 && window.innerWidth < 1250)) {
//Do something
}};
window.onresize = onResizing;
window.onload = onResizing;
Problem
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