<ul dir="auto">
<li>Electron version: 1.4.7</li>
<li>Operating system: OSX 10.12.1</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// in the render
var webview = document.querySelector('webview');

webview.addEventListener('will-navigate', function(e){
    e.preventDefault(); // should prevent webview navigation

    console.log(e);
    // e.defaultPrevented: false
});"><pre class="notranslate"><span class="pl-c">// in the render</span>
<span class="pl-k">var</span> <span class="pl-s1">webview</span> <span class="pl-c1">=</span> <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">querySelector</span><span class="pl-kos">(</span><span class="pl-s">'webview'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-s1">webview</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">'will-navigate'</span><span class="pl-kos">,</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-en">preventDefault</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// should prevent webview navigation</span>

    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-c">// e.defaultPrevented: false</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Also <code class="notranslate">webview.stop()</code> has no effect.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">The webview navigates to the target</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">See code above.</p>
<p dir="auto">It would be very useful to get events related to navigation:</p>
<ul dir="auto">
<li><code class="notranslate">will-navigate</code>: when the webview is about to navigate (url have been changed but no requests have been emited yet). It could eventually be cancelled with <code class="notranslate">event.preventDefault()</code>)</li>
<li><code class="notranslate">page-url-set</code>: like <code class="notranslate">page-title-set</code> but for url. It is different than <code class="notranslate">before-navigate</code> because it should also handle anchor changes and HTML5 url set without navigating (with <code class="notranslate">history.pushState</code> and <code class="notranslate">history.replaceState</code>)</li>
<li><code class="notranslate">did-navigate</code>: after the navigation has occured (i.e. when a new entry have been pushed to history and canGoBack/canGoForward/canGo... may have changed)</li>
</ul>