Pew Pew Laser Blog

Code. Glass art. Games. Baking. Cats. From Seattle, Washington and various sundry satellite locations.

Pew Pew Laser Blog Archives — by Blog ID

On URIs.

5.18.2011

To call an asset (such as an image, stylesheet or JavaScript) from same directory as the current page, then start the URI with the filename. Example:

<img src="happy-kitty.jpg" />

To call something from the same domain as the current page, then start the URI with / and include the directory structure. Example:

<img src="/images/happy-kitty.jpg" />

To use the same protocol as the existing page, start the URI with //, and include the entire directory structure.

<script src="//library/the-script.js"></script>
This is useful for when you need to call assets via HTTPS, but only when your page itself has been delivered to the browser via HTTPS.

To pull in an asset from anywhere in the world wide web, just use the fully qualified URI.

<img src="http://somthing.com/best-kitty.jpg" />

Permalink

Tags: code html

Authorized users may log-in to leave a comment.

Last Blog: Selecting Children in the DOM.

Next Blog: Tales of Shame.