insertCss not working
See original GitHub issueIs it possible to call the insertCSS function of electron webView();? if so how do I do that? I tried
tab = tabGroup.addTab({
title: 'Electron',
src: path.join(appBase, '/views/main-frame/index.html')
visible: true,
active: true,
webviewAttributes: {
nodeintegration: true,
plugins: true
},
ready: function (tab) {
tab.webview.insertCSS("background-color:red;");
}
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Chrome Extension to change Style Elements, insertCSS not ...
I have a working extension with popup HTML and js files. I tried using insertCSS in the content.js but read that it will...
Read more >Chrome Extension to change Style Elements, insertCSS not ...
I have a working extension with popup HTML and js files. I tried using insertCSS in the content.js but read that it will...
Read more >tabs.insertCSS() - Mozilla - MDN Web Docs
To work cross-browser, you can specify the path as an absolute URL, starting at the extension's root, like this: "/path/to/stylesheet.css" .
Read more >WebContents#insertCSS does not work when 'sandbox: true'
Download and unarchive the Gist · Enter the unarchived directory and run npm install · Run ./node_modules/.bin/electron . · Text in <body> is...
Read more >How to add CSS - W3Schools
Three Ways to Insert CSS. There are three ways of inserting ... The external .css file should not contain any HTML tags. Here...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, this is my mistake! Please forget my previous post. Actually you were totally right with your first code, but as it’s specified in electron documentation (here):
So you must wait for the webview to be loaded before using
insertCSS
.Another mistake is the parameter you use in
insertCSS
. It is supposed to be a valid CSS rule with a selector.So this code should work finaly:
Hope this helps.
By the way, I just wrote feature request #9 which can help to handle this in a more convenient way.