The HTML, CSS, and JavaScript files provide the implementation of the widget. In these files, you can use any technique or trick that you would use when designing a webpage. This includes, but is not limited to, HTML, CSS, and JavaScript. Use JavaScript to introduce interactivity into your widget.
While you can place all of your HTML, CSS, and JavaScript code into one file, you may find it more manageable to split these into separate files, as shown in Table 2-1. Splitting your markup, design, and logic into separate files may also make localization easier, as discussed later on in Localizing Widgets. In general, file extensions are used to reflect the purpose of the file:
Technology | Purpose | File extension | Example |
|---|---|---|---|
HTML | Structure |
|
|
CSS | Design |
|
|
JavaScript | Logic |
|
|
These file extensions are not enforced by Dashboard, but it is recommended that you adhere to these standards.
To load your CSS and JavaScript, you'll need to import them inside of your HTML file. For importing a style sheet, the markup looks like this:
<style type="text/css"> |
@import "HelloWorld.css"; |
</style> |
To load a JavaScript file, use the <script> tag:
<script type='text/javascript' src='HelloWorld.js'></script> |
Note that if your widget does not use CSS or JavaScript, there is no need to use these includes or to include blank CSS or JavaScript files. Conversely, you can use multiple @import statements and <script> tags to include more than one CSS or JavaScript file.
Last updated: 2006-01-10