getstarted.html revision 634420e363ef646c3b50a37b10d86a424b06ee49
1<div id="pageData-name" class="pageData">Tutorial: Getting Started (Hello, World!)</div> 2<div id="pageData-showTOC" class="pageData">true</div> 3 4<p> 5This tutorial walks you through creating a simple extension. 6You'll add an icon to Google Chrome 7that, when clicked, displays an automatically generated page. 8The icon and page will look something like this: 9</p> 10 11<img src="images/hello-world-small.png" 12 width="300" height="221" 13 alt="a window with a grid of images related to HELLO WORLD" /> 14 15<p> 16You can develop extensions using any release of Google Chrome, 17on Windows, Mac, or Linux. 18</p> 19 20<h2 id="load">Create and load an extension</h2> 21<p> 22In this section, you'll write an extension 23that adds a <em>browser action</em> 24to the toolbar of Google Chrome. 25</p> 26 27<ol> 28 <li> 29 Create a folder somewhere on your computer to contain your extension's code. 30 </li> 31 <li> 32 Inside your extension's folder, 33 create a text file called <strong><code>manifest.json</code></strong>, 34 and put this in it: 35<pre>{ 36 "name": "My First Extension", 37 "version": "1.0", 38 "description": "The first extension that I made.", 39 "browser_action": { 40 "default_icon": "icon.png" 41 }, 42 "permissions": [ 43 "http://api.flickr.com/" 44 ] 45}</pre> 46 </li> 47 <li> 48 Copy this icon to the same folder:<br> 49 <table cellpadding="0" cellspacing="0" style="border:0"> 50 <tr> 51 <td style="text-align:center; border:0;"><a 52 href="examples/tutorials/getstarted/icon.png" 53 ><img src="examples/tutorials/getstarted/icon.png" 54 width="19" height="19" border="0"></a><br> 55 <a href="examples/tutorials/getstarted/icon.png" 56 >Download icon.png</a></td> 57 </tr> 58 </table> 59 </li> 60 <li id="load-ext"> Load the extension. 61 <ol type="a"> 62 <li style="margin-top:0" /> 63 Bring up the extensions management page 64 by clicking the wrench icon 65 <img src="images/toolsmenu.gif" width="29" height="29" alt="" 66 style="margin-top:0" /> 67 and choosing <b>Tools > Extensions</b>. 68 </li> 69 70 <li> 71 If <b>Developer mode</b> has a + by it, 72 click the + to add developer information to the page. 73 The + changes to a -, 74 and more buttons and information appear. 75 </li> 76 77 <li> 78 Click the <b>Load unpacked extension</b> button. 79 A file dialog appears. 80 </li> 81 82 <li> 83 In the file dialog, 84 navigate to your extension's folder 85 and click <b>OK</b>. 86 </li> 87 </ol> </li> 88 </ol> 89 90<p> 91If your extension is valid, 92its icon appears next to the address bar, 93and information about the extension 94appears in the extensions page, 95as the following screenshot shows. 96</p> 97 98<p> 99<a href="images/load_after.png"><img 100 src="images/load_after_small.png" 101 width="300" height="132" /></a> 102</p> 103 104<h2 id="code">Add code to the extension</h2> 105<p> In this step, you'll make your extension <em>do</em> something besides just look good. </p> 106<ol> 107 <li> 108 <p> Edit <code>manifest.json</code> to add the following line:</p> 109<pre> 110 ... 111 "browser_action": { 112 "default_icon": "icon.png"<b>, 113 "popup": "popup.html"</b> 114 }, 115 ... 116</pre> 117 <p> Inside your extension's folder, 118 create a text file called <strong><code>popup.html</code></strong>, 119 and add the following code to it:</p> 120 <blockquote> <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/tutorials/getstarted/popup.html?content-type=text/plain" 121 target="_blank">CSS 122 and JavaScript code for hello_world</a></blockquote> 123 </li> 124 <li> 125 Return to the extensions management page, 126 and click the <b>Reload</b> button 127 to load the new version of the extension.</li> 128 <li>Click the extension's icon. 129 A popup should appear that displays the contents of 130 <code>popup.html</code>. </li> 131</ol> 132<p> It should look something like this:</p> 133 134<img src="images/hello-world.png" 135 width="500" height="369" 136 alt="a popup with a grid of images related to HELLO WORLD" /> 137 138<p> If you don't see the popup, 139try the instructions again, 140following them exactly. 141Don't try loading an HTML file that isn't in the extension's folder — 142it won't work! </p> 143 144<h2 id="summary">Now what?</h2> 145 146<!-- [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 information.] --> 147 148<p> 149Here are some suggestions for what to read next: 150</p> 151 152<ul> 153 <li> 154 The <a href="overview.html">Overview</a>, 155 which has important conceptual and practical information 156 </li> 157 <li> 158 The 159 <a href="tut_debugging.html">debugging tutorial</a>, 160 which starts where this tutorial leaves off 161 </li> 162 <li> 163 The <a href="hosting.html">hosting</a> page, 164 which tells you about options for distributing your extension 165 </li> 166</ul> 167 168<p> 169If you don't feel like reading, try these: 170</p> 171<ul> 172 <li> 173 Keep up to date with the latest news: 174 <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions/subscribe">subscribe to chromium-extensions</a> 175 </li> 176 <li> 177 Look at some 178 <a href="samples.html">sample extensions</a> 179 </li> 180 <li> 181 Watch some 182 <a href="http://www.youtube.com/view_play_list?p=CA101D6A85FE9D4B">videos</a>, such as 183 <a href="http://www.youtube.com/watch?v=e3McMaHvlBY&feature=PlayList&p=CA101D6A85FE9D4B&index=3">How to build an extension</a> 184 </li> 185</ul> 186