I have this webview that I load like this:
<webview id="link-view"
        src="http://url.espace.com/"
        preload="./preload.js"
        autosize="on"
        partition="persist:link"></webview>
In the preload.js file : I have this
console.log("test");
This doesn't even work..
Can someone explain?
I just tried the same scenario, and it worked as expected.
Do you have the <webview> dev tools open? As a <webview>has its own dev tools, That would be the only reason i can see for the preload script not showing the console.log output. They can be opened by:
var webview = document.getElementById("link-view");
webview.openDevTools();
Or your path to the script is incorrect, which i doubt as you seem sure about that.
Using latest Electron 2.0.0 (beta-5, at the time of this writing), the preload attribute demands a file: (or asar:) protocol followed by an absolute path. Paths such as ./preload.js don't seem to work anymore and raise an exception: Only "file:" protocol is supported in "preload" attribute.
This solved my problem in electron 3.0.0-beta.4 using react.js
<webview src={'http://example.com'} preload={`file://${__dirname}/preload.js`}/>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With