Skip to content

Commit a6f8e6f

Browse files
authored
Merge pull request #206 from JulianGlueck/feat-preventNavigation
Add documentation for window navigation restriction
2 parents 5e5c4e1 + ec503b3 commit a6f8e6f

File tree

1 file changed

+22
-0
lines changed
  • resources/views/docs/desktop/1/the-basics

1 file changed

+22
-0
lines changed

resources/views/docs/desktop/1/the-basics/windows.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,28 @@ Window::open()
394394

395395
This is particularly useful for always-on-top utility windows or menubar applications that should not be visible in Mission Control.
396396

397+
### Restrict navigation within a window
398+
399+
When opening windows that display content that is not under your control (such as external websites), you may want to
400+
restrict the user's navigation options. NativePHP provides two handy methods for this on the `Window` facade:
401+
402+
```php
403+
Window::open()
404+
->url('https://nativephp.com/')
405+
->preventLeaveDomain();
406+
407+
Window::open()
408+
->url('https://laravel-news.com/bifrost')
409+
->preventLeavePage();
410+
```
411+
412+
The `preventLeaveDomain()` method allows navigation within the same domain but blocks any attempt to navigate away to a
413+
different domain, scheme or port.
414+
415+
With `preventLeavePage()` you can strictly confine the user to the initially rendered page. Any attempt to navigate to a
416+
different path (even within the same domain) will be blocked. However, in-page navigation via anchors (e.g. "#section")
417+
and updates to the query string remain permitted.
418+
397419
#### Preventing new windows from popping up
398420

399421
By default, Electron allows additional windows to be opened from a window that was previously opened programmatically.

0 commit comments

Comments
 (0)