OLD | NEW |
| (Empty) |
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | |
2 1) The <head> information in this page is significant, should be uniform | |
3 across api docs and should be edited only with knowledge of the | |
4 templating mechanism. | |
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | |
6 browser, it will be re-generated from the template, json schema and | |
7 authored overview content. | |
8 4) The <body>.innerHTML is also generated by an offline step so that this | |
9 page may easily be indexed by search engines. | |
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | |
11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> | |
13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> | |
14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla
te_compiled.js"> | |
15 </script> | |
16 <script type="text/javascript" src="../../../../third_party/json_minify/mini
fy-sans-regexp.js"> | |
17 </script> | |
18 <script type="text/javascript" src="js/api_page_generator.js"></script> | |
19 <script type="text/javascript" src="js/bootstrap.js"></script> | |
20 <script type="text/javascript" src="js/sidebar.js"></script> | |
21 <title>Tutorial: Getting Started (Hello, World!) - Google Chrome Extensions -
Google Code</title></head> | |
22 <body> <div id="devModeWarning" class="displayModeWarning"> | |
23 You are viewing extension docs in chrome via the 'file:' scheme: are you exp
ecting to see local changes when you refresh? You'll need run chrome with --allo
w-file-access-from-files. | |
24 </div> | |
25 <div id="branchWarning" class="displayModeWarning"> | |
26 <span>WARNING: This is the <span id="branchName">BETA</span> documentation. | |
27 It may not work with the stable release of Chrome.</span> | |
28 <select id="branchChooser"> | |
29 <option>Choose a different version... | |
30 </option><option value="">Stable | |
31 </option><option value="beta">Beta | |
32 </option><option value="dev">Dev | |
33 </option><option value="trunk">Trunk | |
34 </option></select> | |
35 </div> | |
36 <div id="unofficialWarning" class="displayModeWarning"> | |
37 <span>WARNING: This is unofficial documentation. It may not work with the | |
38 current release of Chrome.</span> | |
39 <button id="goToOfficialDocs">Go to the official docs</button> | |
40 </div> | |
41 <div id="gc-container" class="labs"> | |
42 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> | |
43 <!-- In particular, sub-templates that recurse, must be used by allowing | |
44 jstemplate to make a copy of the template in this section which | |
45 are not operated on by way of the jsskip="true" --> | |
46 <!-- /SUBTEMPLATES --> | |
47 <a id="top"></a> | |
48 <div id="skipto"> | |
49 <a href="#gc-pagecontent">Skip to page content</a> | |
50 <a href="#gc-toc">Skip to main navigation</a> | |
51 </div> | |
52 <!-- API HEADER --> | |
53 <table id="header" width="100%" cellspacing="0" border="0"> | |
54 <tbody><tr> | |
55 <td valign="middle"><a href="http://code.google.com/"><img src="images/c
ode_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:
0; margin:0;"></a></td> | |
56 <td valign="middle" width="100%" style="padding-left:0.6em;"> | |
57 <form action="http://www.google.com/cse" id="cse" style="margin-top:0.
5em"> | |
58 <div id="gsc-search-box"> | |
59 <input type="hidden" name="cx" value="002967670403910741006:61_cvz
fqtno"> | |
60 <input type="hidden" name="ie" value="UTF-8"> | |
61 <input type="text" name="q" value="" size="55"> | |
62 <input class="gsc-search-button" type="submit" name="sa" value="Se
arch"> | |
63 <br> | |
64 <span class="greytext">e.g. "page action" or "tabs"</span> | |
65 </div> | |
66 </form> | |
67 <script type="text/javascript" src="https://www.google.com/jsapi"></sc
ript> | |
68 <script type="text/javascript">google.load("elements", "1", {packages:
"transliteration"});</script> | |
69 <script type="text/javascript" src="https://www.google.com/coop/cse/t1
3n?form=cse&t13n_langs=en"></script> | |
70 <script type="text/javascript" src="https://www.google.com/coop/cse/br
and?form=cse&lang=en"></script> | |
71 </td> | |
72 </tr> | |
73 </tbody></table> | |
74 <div id="codesiteContent" class=""> | |
75 <a id="gc-topnav-anchor"></a> | |
76 <div id="gc-topnav"> | |
77 <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Lab
s</a>)</h1> | |
78 <ul id="home" class="gc-topnav-tabs"> | |
79 <li id="home_link"> | |
80 <a href="index.html" title="Google Chrome Extensions home page">Home
</a> | |
81 </li> | |
82 <li id="docs_link"> | |
83 <a href="docs.html" title="Official Google Chrome Extensions documen
tation">Docs</a> | |
84 </li> | |
85 <li id="faq_link"> | |
86 <a href="faq.html" title="Answers to frequently asked questions abou
t Google Chrome Extensions">FAQ</a> | |
87 </li> | |
88 <li id="samples_link"> | |
89 <a href="samples.html" title="Sample extensions (with source code)">
Samples</a> | |
90 </li> | |
91 <li id="group_link"> | |
92 <a href="http://groups.google.com/a/chromium.org/group/chromium-exte
nsions" title="Google Chrome Extensions developer forum">Group</a> | |
93 </li> | |
94 <li id="so_link"> | |
95 <a href="http://stackoverflow.com/questions/tagged/google-chrome-ext
ension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a> | |
96 </li> | |
97 </ul> | |
98 </div> <!-- end gc-topnav --> | |
99 <div class="g-section g-tpl-170"> | |
100 <!-- SIDENAV --> | |
101 <div class="g-unit g-first" id="gc-toc"> | |
102 <ul> | |
103 <li class="leftNavSelected">Getting Started</li> | |
104 <li><a href="overview.html">Overview</a></li> | |
105 <li><a href="whats_new.html">What's New?</a></li> | |
106 <li><h2><a href="devguide.html">Developer's Guide</a></h2> | |
107 <ul> | |
108 <li>Browser UI | |
109 <ul> | |
110 <li><a href="browserAction.html">Browser Actions</a></li> | |
111 <li><a href="contextMenus.html">Context Menus</a></li> | |
112 <li><a href="notifications.html">Desktop Notifications</a></li
> | |
113 <li><a href="omnibox.html">Omnibox</a></li> | |
114 <li><a href="options.html">Options Pages</a></li> | |
115 <li><a href="override.html">Override Pages</a></li> | |
116 <li><a href="pageAction.html">Page Actions</a></li> | |
117 </ul> | |
118 </li> | |
119 <li>Browser Interaction | |
120 <ul> | |
121 <li><a href="bookmarks.html">Bookmarks</a></li> | |
122 <li><a href="cookies.html">Cookies</a></li> | |
123 <li><a href="devtools.html">Developer Tools</a></li> | |
124 <li><a href="events.html">Events</a></li> | |
125 <li><a href="history.html">History</a></li> | |
126 <li><a href="management.html">Management</a></li> | |
127 <li><a href="tabs.html">Tabs</a></li> | |
128 <li><a href="windows.html">Windows</a></li> | |
129 </ul> | |
130 </li> | |
131 <li>Implementation | |
132 <ul> | |
133 <li><a href="a11y.html">Accessibility</a></li> | |
134 <li><a href="background_pages.html">Background Pages</a></li> | |
135 <li><a href="content_scripts.html">Content Scripts</a></li> | |
136 <li><a href="xhr.html">Cross-Origin XHR</a></li> | |
137 <li><a href="i18n.html">Internationalization</a></li> | |
138 <li><a href="messaging.html">Message Passing</a></li> | |
139 <li><a href="permissions.html">Optional Permissions</a></li> | |
140 <li><a href="npapi.html">NPAPI Plugins</a></li> | |
141 </ul> | |
142 </li> | |
143 <li>Finishing | |
144 <ul> | |
145 <li><a href="hosting.html">Hosting</a></li> | |
146 <li><a href="external_extensions.html">Other Deployment Option
s</a></li> | |
147 </ul> | |
148 </li> | |
149 </ul> | |
150 </li> | |
151 <li><h2><a href="apps.html">Packaged Apps</a></h2></li> | |
152 <li><h2><a href="tutorials.html">Tutorials</a></h2> | |
153 <ul> | |
154 <li><a href="tut_debugging.html">Debugging</a></li> | |
155 <li><a href="tut_analytics.html">Google Analytics</a></li> | |
156 <li><a href="tut_oauth.html">OAuth</a></li> | |
157 </ul> | |
158 </li> | |
159 <li><h2>Reference</h2> | |
160 <ul> | |
161 <li>Formats | |
162 <ul> | |
163 <li><a href="manifest.html">Manifest Files</a></li> | |
164 <li><a href="match_patterns.html">Match Patterns</a></li> | |
165 </ul> | |
166 </li> | |
167 <li><a href="permission_warnings.html">Permission Warnings</a></li
> | |
168 <li><a href="api_index.html">chrome.* APIs</a></li> | |
169 <li><a href="api_other.html">Other APIs</a></li> | |
170 </ul> | |
171 </li> | |
172 <li><h2><a href="samples.html">Samples</a></h2></li> | |
173 <div class="line"> </div> | |
174 <li><h2>More</h2> | |
175 <ul> | |
176 <li><a href="http://code.google.com/chrome/webstore/docs/index.htm
l">Chrome Web Store</a></li> | |
177 <li><a href="http://code.google.com/chrome/apps/docs/developers_gu
ide.html">Hosted Apps</a></li> | |
178 <li><a href="themes.html">Themes</a></li> | |
179 </ul> | |
180 </li> | |
181 </ul> | |
182 </div> | |
183 <script> | |
184 initToggles(); | |
185 </script> | |
186 <div class="g-unit" id="gc-pagecontent"> | |
187 <div id="pageTitle"> | |
188 <h1 class="page_title">Tutorial: Getting Started (Hello, World!)</h1> | |
189 </div> | |
190 <!-- TABLE OF CONTENTS --> | |
191 <div id="toc"> | |
192 <h2>Contents</h2> | |
193 <ol> | |
194 <li> | |
195 <a href="#load">Create and load an extension</a> | |
196 <ol> | |
197 </ol> | |
198 </li><li> | |
199 <a href="#code">Add code to the extension</a> | |
200 <ol> | |
201 </ol> | |
202 </li><li> | |
203 <a href="#summary">Now what?</a> | |
204 <ol> | |
205 </ol> | |
206 </li> | |
207 </ol> | |
208 </div> | |
209 <!-- /TABLE OF CONTENTS --> | |
210 <!-- Standard content lead-in for experimental API pages --> | |
211 <!-- STATIC CONTENT PLACEHOLDER --> | |
212 <div id="static"><div id="pageData-name" class="pageData">Tutorial: Gett
ing Started (Hello, World!)</div> | |
213 <div id="pageData-showTOC" class="pageData">true</div> | |
214 <p> | |
215 This tutorial walks you through creating a simple extension. You'll add an | |
216 icon to Google Chrome that, when clicked, displays an automatically generated | |
217 page. The icon and page will look something like this: | |
218 </p> | |
219 <img src="images/hello-world-small.png" width="300" height="221" alt="a window w
ith a grid of images related to 'Hello World'"> | |
220 <p> | |
221 You can develop extensions using any release of Google Chrome, on Windows, | |
222 Mac, or Linux. Extensions you develop on one platform should run without | |
223 change on every platform Chrome supports. | |
224 </p> | |
225 <h2 id="load">Create and load an extension</h2> | |
226 <p> | |
227 The extension we'll walk through creating here is a | |
228 <a href="browserAction.html">Browser Action</a>, which adds a button to | |
229 Chrome's toolbar whose behavior you can control. | |
230 </p> | |
231 <ol> | |
232 <li> | |
233 Create a folder somewhere on your computer to contain your extension's code. | |
234 </li> | |
235 <li> | |
236 <p> | |
237 Inside your extension's folder, create a text file called | |
238 <strong><code>manifest.json</code></strong>, and fill it with the | |
239 following code: | |
240 </p> | |
241 <pre>{ | |
242 "name": "My First Extension", | |
243 "version": "1.0", | |
244 "manifest_version": 2, | |
245 "description": "The first extension that I made.", | |
246 "browser_action": { | |
247 "default_icon": "icon.png" | |
248 }, | |
249 "permissions": [ | |
250 "http://api.flickr.com/" | |
251 ] | |
252 }</pre> | |
253 </li> | |
254 <li> | |
255 <p>Copy this icon to the same folder:</p> | |
256 <div style="width: 150px; text-align: center;"> | |
257 <a href="examples/tutorials/getstarted/icon.png" download="icon"> | |
258 <img src="examples/tutorials/getstarted/icon.png" width="19" height="19"
alt="" style="display: block; margin: 0.25em auto;"> | |
259 Download icon.png | |
260 </a> | |
261 </div> | |
262 </li> | |
263 <li id="load-ext"> | |
264 <p>Load the extension.</p> | |
265 <ol type="a"> | |
266 <li style="margin-top:0"> | |
267 Bring up the extensions management page | |
268 by clicking the wrench icon | |
269 <img src="images/toolsmenu.gif" width="29" height="29" alt="" style="margi
n-top:0"> | |
270 and choosing <b>Tools > Extensions</b>. | |
271 </li> | |
272 <li> | |
273 If <b>Developer mode</b> has a + by it, | |
274 click the + to add developer information to the page. | |
275 The + changes to a -, | |
276 and more buttons and information appear. | |
277 </li> | |
278 <li> | |
279 Click the <b>Load unpacked extension</b> button. | |
280 A file dialog appears. | |
281 </li> | |
282 <li> | |
283 In the file dialog, | |
284 navigate to your extension's folder | |
285 and click <b>OK</b>. | |
286 </li> | |
287 </ol> </li> | |
288 </ol> | |
289 <p> | |
290 If your extension is valid, | |
291 its icon appears next to the address bar, | |
292 and information about the extension | |
293 appears in the extensions page, | |
294 as the following screenshot shows. | |
295 </p> | |
296 <p> | |
297 <a href="images/load_after.png"><img src="images/load_after_small.png" width="30
0" height="132"></a> | |
298 </p> | |
299 <h2 id="code">Add code to the extension</h2> | |
300 <p> | |
301 In this step, you'll make your extension <em>do</em> something besides just | |
302 look good. | |
303 </p> | |
304 <ol> | |
305 <li> | |
306 <p>Edit <code>manifest.json</code> to add the following line:</p> | |
307 <pre>... | |
308 "browser_action": { | |
309 "default_icon": "icon.png"<b>, | |
310 "default_popup": "popup.html"</b> | |
311 }, | |
312 ...</pre> | |
313 <p> | |
314 Inside your extension's folder, create two text files called | |
315 <strong><code>popup.html</code></strong> and | |
316 <strong><code>popup.js</code></strong>. Add the following code to | |
317 these files: | |
318 </p> | |
319 <blockquote> | |
320 <a href="examples/tutorials/getstarted/popup.html" target="_blank">HTML co
de (popup.html)</a> and | |
321 <a href="examples/tutorials/getstarted/popup.js" target="_blank">JavaScript
code (popup.js)</a> for hello_world </blockquote> | |
322 </li> | |
323 <li> | |
324 Return to the extensions management page, | |
325 and click the <b>Reload</b> button | |
326 to load the new version of the extension.</li> | |
327 <li>Click the extension's icon. | |
328 A popup should appear that displays the contents of | |
329 <code>popup.html</code>. </li> | |
330 </ol> | |
331 <p> It should look something like this:</p> | |
332 <img src="images/hello-world.png" width="500" height="369" alt="a popup with a g
rid of images related to HELLO WORLD"> | |
333 <p> If you don't see the popup, | |
334 try the instructions again, | |
335 following them exactly. | |
336 Don't try loading an HTML file that isn't in the extension's folder — | |
337 it won't work! </p> | |
338 <h2 id="summary">Now what?</h2> | |
339 <!-- [PENDING: Summarize what we did, what it means, what else we would've done
if this were a real extension (e.g. package/zip it), and where to find more info
rmation.] --> | |
340 <p> | |
341 Here are some suggestions for what to read next: | |
342 </p> | |
343 <ul> | |
344 <li> | |
345 The <a href="overview.html">Overview</a>, | |
346 which has important conceptual and practical information | |
347 </li> | |
348 <li> | |
349 The | |
350 <a href="tut_debugging.html">debugging tutorial</a>, | |
351 which starts where this tutorial leaves off | |
352 </li> | |
353 <li> | |
354 The <a href="hosting.html">hosting</a> page, | |
355 which tells you about options for distributing your extension | |
356 </li> | |
357 </ul> | |
358 <p> | |
359 If you don't feel like reading, try these: | |
360 </p> | |
361 <ul> | |
362 <li> | |
363 Keep up to date with the latest news: | |
364 <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions/s
ubscribe">subscribe to chromium-extensions</a> | |
365 </li> | |
366 <li> | |
367 Ask a question tagged [google-chrome-extension] on | |
368 <a href="http://stackoverflow.com/questions/tagged/google-chrome-extension">
Stack Overflow</a> | |
369 </li> | |
370 <li> | |
371 Look at some | |
372 <a href="samples.html">sample extensions</a> | |
373 </li> | |
374 <li> | |
375 Watch some | |
376 <a href="http://www.youtube.com/view_play_list?p=CA101D6A85FE9D4B">videos</a
>, such as | |
377 <a href="http://www.youtube.com/watch?v=e3McMaHvlBY&feature=PlayList&
;p=CA101D6A85FE9D4B&index=3">How to build an extension</a> | |
378 </li> | |
379 </ul> | |
380 </div> | |
381 <!-- API PAGE --> | |
382 <!-- /apiPage --> | |
383 </div> <!-- /gc-pagecontent --> | |
384 </div> <!-- /g-section --> | |
385 </div> <!-- /codesiteContent --> | |
386 <div id="gc-footer" --=""> | |
387 <div class="text"> | |
388 <p> | |
389 Except as otherwise <a href="http://code.google.com/policies.html#restrictions
">noted</a>, | |
390 the content of this page is licensed under the <a rel="license" href="http://c
reativecommons.org/licenses/by/3.0/">Creative Commons | |
391 Attribution 3.0 License</a>, and code samples are licensed under the | |
392 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic
ense</a>. | |
393 </p> | |
394 <p> | |
395 ©2011 Google | |
396 </p> | |
397 <!-- begin analytics --> | |
398 <script src="https://www.google-analytics.com/urchin.js" type="text/javascript">
</script> | |
399 <script src="https://www.google-analytics.com/ga.js" type="text/javascript"></sc
ript> | |
400 <script type="text/javascript"> | |
401 // chrome doc tracking | |
402 try { | |
403 var engdocs = _gat._getTracker("YT-10763712-2"); | |
404 engdocs._trackPageview(); | |
405 } catch(err) {} | |
406 // code.google.com site-wide tracking | |
407 try { | |
408 _uacct="UA-18071-1"; | |
409 _uanchor=1; | |
410 _uff=0; | |
411 urchinTracker(); | |
412 } | |
413 catch(e) {/* urchinTracker not available. */} | |
414 </script> | |
415 <!-- end analytics --> | |
416 </div> | |
417 </div> <!-- /gc-footer --> | |
418 </div> <!-- /gc-container --> | |
419 </body></html> | |
OLD | NEW |