0

I've read about Window.showDirectoryPicker() here and it should be supported by Google Chrome 107, so I don't understand why I'm not seeing a window popup to select a directory!

const butDir = document.getElementById('butDirectory');
butDir.addEventListener('click', async () => {
  const dirHandle = await window.showDirectoryPicker();
  for await (const entry of dirHandle.values()) {
    console.log(entry.kind, entry.name);
  }
});
body {
  background: #6e28d9;
  padding: 0 24px;
  margin: 0;
  height: 100vh;
  color: white;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="src/style.css">
  </head>
  <body>
    <h1>Hi friend, try edit me!</h1>
    <p>Just some text</p>
    <input type="button" id="butDirectory" value="Open Directory">
    
  </body>
  <script src="src/script.js"></script>
</html>
Olivier
  • 607
  • 1
  • 6
  • 21

1 Answers1

0

Sorry! It's actually working, but it needs to be opened in its own tab entirely, i.e. not in JSFiddle!

Olivier
  • 607
  • 1
  • 6
  • 21