Jump to content

check outerwidth


ila_rigo

Recommended Posts

<!DOCTYPE html>
<html>
<body>

<p>Display "iphone" if the outherWidth is equal or less than 320px</p>

<p id="demo">desktop</p>

<script>

function checkOuterWidth(){

var w = window.outerWidth;
    
if (w <= 320) {
   document.getElementById("demo").innerHTML = "iphone";
}
else {
   document.getElementById("demo").innerHTML = "desktop";
}
}

</script>
</body>
</html>

Hello,
i am trying to write a function to detect the browser width and, based on that, have two different results. I have looked at some examples and tried to reproduce some tutorials but at the moment it doesn't work ... suggestions and corrections are very welcome

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...