Master_T
Master_T

Reputation: 7943

Chromium / Puppetter: hiding the URL bar

I'm using Puppeteer to show a Chromium window. However, I would like to hide the address bar (i.e.: where you can input the URL) so that the user cannot navigate away from the page I've set.

Is this possible? I've tried passing the --kiosk command line argument, but this forces the browser to go fullscreen, which I don't want, I still want it to be in a window. Is there any way to do it?

Upvotes: 0

Views: 2289

Answers (1)

Md. Abu Taher
Md. Abu Taher

Reputation: 18836

You can do the following as long as chromium supports Apps,

(async () => {
  const browser = await puppeteer.launch({ headless: false, args: ['--app=http://example.com'] });
  const [page] = await browser.pages();
  await page.screenshot({path: 'example.png'});
  await browser.close();
})();

What's happening:

  • The --app= argument will make it open in app mode (not fullscreen, no url bar, it's a window etc.).
  • browser.pages() will return the current open pages in an array.

Upvotes: 3

Related Questions