mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
Only open http/https links
This commit is contained in:
@@ -606,7 +606,10 @@ The following example code opens the new url in system's default browser.
|
||||
|
||||
```javascript
|
||||
webview.addEventListener('new-window', function(e) {
|
||||
require('electron').shell.openExternal(e.url);
|
||||
var protocol = require('url').parse(e.url).protocol;
|
||||
if (protocol === 'http:' || protocol === 'https:') {
|
||||
require('electron').shell.openExternal(e.url);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user