rlr/dotjs-addon — Issue #12: Suggestion: documentation for path cibling
Author: bpierre
Created: 2011-12-08 20:47:03+00:00
State: open

Sometimes, you don’t want to target a whole domain, but only a path.

You could add this to the documentation:

# How to target a specific path

## CSS

You can use the `@-moz-document` Mozilla Extension:

/* Full path */
@-moz-document url-prefix(http://www.w3.org/Style/) {
/* CSS here */
}

/* Regex */
@-moz-document regexp("^https?:\/\/www\.w3\.org\/Style\/.*") {
/* CSS here */
}

Documentation: https://developer.mozilla.org/en/CSS/@-moz-document

## JavaScript

You can test the `window.location` object:

// Search for a string
if (window.location.pathname.indexOf('/Style/') === 0) {
// JS here
}

// Regex
if (/^\/Style\/.*/.test(window.location.pathname)) === 0) {
// JS here
}

Documentation: https://developer.mozilla.org/en/DOM/window.location