Skip to content

Instantly share code, notes, and snippets.

@advancedor96
Created February 8, 2018 14:12
Show Gist options
  • Save advancedor96/e83b38408ae1e1e965b9d9b6551b5e90 to your computer and use it in GitHub Desktop.
Save advancedor96/e83b38408ae1e1e965b9d9b6551b5e90 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body{
margin: 0;
}
</style>
</head>
<body>
<canvas id="WhackAWorm" width="500" height="500"></canvas>
window.innerWidth為:<p id="show"></p>
<script>
init = ()=>{
console.log('window.innerWidth:',window.innerWidth);
document.querySelector('#show').innerHTML = window.innerWidth + 'px';
}
window.addEventListener('load', init);
window.addEventListener('resize', init);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment