OLD | NEW |
1 <div id="pageData-name" class="pageData">Background Pages</div> | 1 <h1>Background Pages</h1> |
2 <div id="pageData-showTOC" class="pageData">true</div> | 2 |
3 | 3 |
4 <p id="eventPageWarning" class="warning"> | 4 <p id="eventPageWarning" class="warning"> |
5 <em>Caution:</em> Consider using event pages instead. | 5 <em>Caution:</em> Consider using event pages instead. |
6 <a href="event_pages.html">Learn more</a>. | 6 <a href="event_pages.html">Learn more</a>. |
7 </p> | 7 </p> |
8 | 8 |
9 <p> | 9 <p> |
10 A common need for extensions is to have | 10 A common need for extensions is to have |
11 a single long-running script to manage some task or state. | 11 a single long-running script to manage some task or state. |
12 Background pages to the rescue. | 12 Background pages to the rescue. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 such as user clicks. | 107 such as user clicks. |
108 </p> | 108 </p> |
109 | 109 |
110 <p> | 110 <p> |
111 The extension in this example | 111 The extension in this example |
112 has a background page | 112 has a background page |
113 and multiple pages created | 113 and multiple pages created |
114 (with | 114 (with |
115 <a href="tabs.html#method-create"><code>chrome.tabs.create()</code></a>) | 115 <a href="tabs.html#method-create"><code>chrome.tabs.create()</code></a>) |
116 from a file named <code>image.html</code>. | 116 from a file named <code>image.html</code>. |
117 <!-- [PENDING: Once we have our set of samples, we should point to the example t
his is from and to other relevant examples. This is currently untested code der
ived from the screenshot sample.] --> | 117 |
118 </p> | 118 </p> |
119 | 119 |
120 <pre> | 120 <pre> |
121 <em>//In background.js:</em> | 121 <em>//In background.js:</em> |
122 // React when a browser action's icon is clicked. | 122 // React when a browser action's icon is clicked. |
123 chrome.browserAction.onClicked.addListener(function(tab) { | 123 chrome.browserAction.onClicked.addListener(function(tab) { |
124 var viewTabUrl = chrome.extension.getURL('image.html'); | 124 var viewTabUrl = chrome.extension.getURL('image.html'); |
125 var imageUrl = <em>/* an image's URL */</em>; | 125 var imageUrl = <em>/* an image's URL */</em>; |
126 | 126 |
127 // Look through all the pages in this extension to find one we can use. | 127 // Look through all the pages in this extension to find one we can use. |
(...skipping 22 matching lines...) Expand all Loading... |
150 | 150 |
151 <body> | 151 <body> |
152 <p> | 152 <p> |
153 Image here: | 153 Image here: |
154 </p> | 154 </p> |
155 | 155 |
156 <img id="target" src="white.png" width="640" height="480"> | 156 <img id="target" src="white.png" width="640" height="480"> |
157 | 157 |
158 </body> | 158 </body> |
159 </html> | 159 </html> |
160 </pre> | 160 </pre> |
OLD | NEW |