1

I'm looking for a way to maximize the Safari window using JavaScript for Automation (JXA).

I'm able to open Safari and to bring the window to front, but I can't find a way to open it in fullscreen.

var safari = Application('Safari');
safari.includeStandardAdditions = true; 
safari.quit(); // Avoid having multiple Safari windows open
safari.activate(); // Start Safari and bring to front  
var document = safari.documents[0];
document.url = 'http://stackoverflow.com';

1 Answers1

2

To go full screen in Safari, you could code…

var se = Application('System Events');
delay(1);
se.keystroke('f', { using: ['control down','command down'] });

Put it after your code.

JakeCigar
  • 603
  • 6
  • 12