JavaScript Window history Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

window.history is the History object for this tab. Use history.back(), forward(), and go() to move through entries.

Syntax

Read window.history with no parentheses.

JavaScript
window.history;
CallWhat it does
window.historySession history for this tab.

Window property in browsers. No import required.

Parameters

ParameterDescription
window.historyRead-only or assignable depending on the property. No function arguments.

Return Value

Return ValueDescription
*Session history for this tab.

JavaScript Examples

Example 1 — Basic Read

Beginner example for window.history.

JavaScript
console.log(typeof window.history.length);
console.log(window.history.length >= 1);
Try It Yourself

How It Works

  1. Step. length counts session history entries.
  2. Step. At least one for the current page.

Example 2 — Practical Use

Beginner example for window.history.

JavaScript
console.log(window.history === history);
console.log(typeof history.back);
Try It Yourself

How It Works

  1. Step. Global history matches window.history.
  2. Step. back/forward/go are methods.

Example 3 — Check / Compare

Beginner example for window.history.

JavaScript
console.log(typeof history.pushState);
Try It Yourself

How It Works

  1. Step. SPA routing uses pushState and replaceState.

Browser & Runtime Support

window.history is a standard Window property in browsers.

✓ Browser Window API

window.history

Available in all modern browsers. Not used in plain Node.js without a DOM.

Browsers Environment
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
window.history Excellent

Bottom line: Safe in browsers. Skip in server-only Node scripts.

Frequently Asked Questions

The session history API for this tab.
How many entries exist in this session’s history stack.
No. Browsers hide other entries for privacy.
Open the Window Properties index for every property in this series.

Browse more properties

Continue through the Window properties list.

Next →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful