This website requires JavaScript.

May 3, 2024

Get all non native window variables

Get all non native window variables
Copy
js
// Get all non native window variables

(function showAllNonNativeWindowProperties() {
  const iframe = document.createElement("iframe");
  iframe.style.display = "none";
  document.body.appendChild(iframe);

  const currentWindowProps = Object.getOwnPropertyNames(window);

  const allNonNativeProps = currentWindowProps.filter(function (prop) {
    return !iframe.contentWindow.hasOwnProperty(prop);
  });

  for (const prop of allNonNativeProps.sort()) {
    console.log(`Saabbir ${prop}: `, window[`${prop}`]);
  }

  document.body.removeChild(iframe);
})();

Further reading