# scroll lock

[🔰 JS](../../../../../js) ⟩ [browser](../../../..) ⟩ [DOM](../../..) ⟩ [types](../..) ⟩ [Window](..) ⟩ [scrolling]() ⟩ lock

{% tabs %}
{% tab title="💾 程式" %}
```javascript
function lockScroll(locked=true){
    document.body.style.overflow = locked ? "hidden" : '';
}
```
{% endtab %}

{% tab title="📗 參考" %}
* [ ] JS.info ⟩ [Forbid the scrolling](https://javascript.info/size-and-scroll-window#forbid-the-scrolling)
{% endtab %}
{% endtabs %}
