@rtorcato/browser-common / window
window
Functions
openWindow()
openWindow(
url,target?,features?):Window|null
Defined in: window/index.ts:13
Opens a new browser window or tab with the given URL.
Parameters
url
string
The URL to open.
target?
string = '_blank'
The target window name (e.g., '_blank', '_self').
features?
string
Optional features string (e.g., 'width=600,height=400').
Returns
Window | null
The window object or null if blocked.
Example
import { openWindow } from '@rtorcato/browser-common/window'
openWindow('https://example.com', '_blank')
closeWindow()
closeWindow():
void
Defined in: window/index.ts:29
Closes the current browser window (if allowed).
Returns
void
Example
import { closeWindow } from '@rtorcato/browser-common/window'
closeWindow()
focusWindow()
focusWindow():
void
Defined in: window/index.ts:41
Focuses the current browser window.
Returns
void
Example
import { focusWindow } from '@rtorcato/browser-common/window'
focusWindow()
blurWindow()
blurWindow():
void
Defined in: window/index.ts:53
Blurs (removes focus from) the current browser window.
Returns
void
Example
import { blurWindow } from '@rtorcato/browser-common/window'
blurWindow()
scrollToTop()
scrollToTop(
behavior?):void
Defined in: window/index.ts:66
Scrolls the window to the top.
Parameters
behavior?
ScrollBehavior = 'auto'
The scroll behavior ('auto' or 'smooth').
Returns
void
Example
import { scrollToTop } from '@rtorcato/browser-common/window'
scrollToTop('smooth')
scrollToBottom()
scrollToBottom(
behavior?):void
Defined in: window/index.ts:79
Scrolls the window to the bottom.
Parameters
behavior?
ScrollBehavior = 'auto'
The scroll behavior ('auto' or 'smooth').
Returns
void
Example
import { scrollToBottom } from '@rtorcato/browser-common/window'
scrollToBottom('smooth')
reloadWindow()
reloadWindow():
void
Defined in: window/index.ts:92
Reloads the current browser window.
Returns
void
Example
import { reloadWindow } from '@rtorcato/browser-common/window'
reloadWindow()
getWindowSize()
getWindowSize():
object
Defined in: window/index.ts:105
Gets the current window size.
Returns
object
The window's width and height.
width
width:
number
height
height:
number
Example
import { getWindowSize } from '@rtorcato/browser-common/window'
const { width, height } = getWindowSize()
onWindowResize()
onWindowResize(
callback): () =>void
Defined in: window/index.ts:120
Adds a listener for window resize events.
Parameters
callback
() => void
The callback to run on resize.
Returns
A function to remove the event listener.
() => void
Example
import { onWindowResize } from '@rtorcato/browser-common/window'
const off = onWindowResize(() => console.log(window.innerWidth))
off()