Browse Source

docs: add sample code for contents.insertCSS() (#16959)

it not work before Event: 'did-finish-load', so add this sample code to show it.
Gavin Wang 6 years ago
parent
commit
391f6dd663
1 changed files with 6 additions and 0 deletions
  1. 6 0
      docs/api/web-contents.md

+ 6 - 0
docs/api/web-contents.md

@@ -943,6 +943,12 @@ Returns `String` - The user agent for this web page.
 
 Injects CSS into the current web page.
 
+```js
+contents.on('did-finish-load', function () {
+  contents.insertCSS('html, body { background-color: #f00; }')
+})
+```
+
 #### `contents.executeJavaScript(code[, userGesture, callback])`
 
 * `code` String