Skip to content

Commit a54b54e

Browse files
Christywlrogerwang
authored andcommitted
[doc] Update 'webview Tag.md'
1 parent ff9b366 commit a54b54e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

docs/References/webview Tag.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
[TOC]
55

6-
Use the `<webview>` tag to embed 'guest' content (such as web pages) in your app. Different from the `<iframe>`, the `<webview>` runs in a separate process than your app; it doesn't have the same permissions as your app and all interactions between your app and embedded content will be asynchronous. This keeps your app safe from the embedded content.
6+
Use the `<webview>` tag to embed `guest` content (such as web pages) in your app. Different from the `<iframe>`, the `<webview>` runs in a separate process than your app; it doesn't have the same permissions as your app and all interactions between your app and embedded content will be asynchronous. This keeps your app safe from the embedded content.
77

88
## Synopsis
99

1010
To embed a web page in your app, add the webview tag to your app's embedder page (this is the app page that will display the guest content). In its simplest form, the webview tag includes the src of the web page and css styles that control the appearance of the webview container:
1111

1212
```html
13-
<webview id="foo" src="http://www.google.com/" style="width:640px; height:480px"></webview>
13+
<webview id="foo" src="http://www.google.com/" style="width:640px; height:480px">
14+
</webview>
1415
```
1516

1617
## References
@@ -38,24 +39,27 @@ Add the following permission to the manifest:
3839
}
3940
```
4041

41-
and add 'partition="trusted"' attribute to the webview tag.
42+
and add `partition="trusted"` attribute to the webview tag.
4243

4344
### Node.js support in webview
4445

4546
To enable Node.js support in WebView, add the `allownw` attribute to the webview tag. Then Node.js will be turned on, no matter it loads local file or remote site. Use this feature with caution because webview is normally supposed to load untrusted contents.
4647

4748
### executeScript in main world
4849

49-
The [executeScript function in Chrome](https://developer.chrome.com/apps/tags/webview#method-executeScript) lets you inject JS code into webview, but in a isolated world. To access JS objects in the target DOM context, you can inject code into the main world context instead. Simply adding `{mainWorld: true}` to `InjectDetails` typed parameter of the function.
50+
The [executeScript function in Chrome](https://developer.chrome.com/apps/tags/webview#method-executeScript) lets you inject JS code into webview, but in an isolated world. To access JS objects in the target DOM context, you can inject code into the main world context instead. Simply adding `{mainWorld: true}` to `InjectDetails` typed parameter of the function.
5051

5152
### Cookies support in webview
5253

53-
Webview has 'getCookieStoreId()' function which returns storeId which can be used in [chrome.cookies](https://developer.chrome.com/extensions/cookies) API.
54+
Webview has `getCookieStoreId()` function which returns storeId which can be used in [chrome.cookies](https://developer.chrome.com/extensions/cookies) API.
5455

5556
##### Example in console:
56-
Lets assume you have simple NW.js app with webview.
57+
Let's assume you have simple NW.js app with webview.
5758

5859
Show all cookies for e.g. http://docs.nwjs.io in console (to have some cookies there you need to visit page first):
59-
```html
60-
chrome.cookies.getAll({url:"http://docs.nwjs.io", storeId:webview.getCookieStoreId()}, console.log.bind(console));
61-
```
60+
```javascript
61+
chrome.cookies.getAll({
62+
url:"http://docs.nwjs.io",
63+
storeId:webview.getCookieStoreId()
64+
}, console.log.bind(console));
65+
```

0 commit comments

Comments
 (0)