Merge pull request #4959 from atom/check-url-before-opening
Only open http/https links in new-window example
This commit is contained in:
commit
9e2dd13f9a
1 changed files with 4 additions and 1 deletions
|
@ -606,7 +606,10 @@ The following example code opens the new url in system's default browser.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
webview.addEventListener('new-window', function(e) {
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue