Elementals.js

Latest Version: 3.7 Final 20 December 2018

Method _.Load.style

Summary:

Loads a stylesheet by adding a <link rel="stylesheet"> to the document.head

Calling Convention:
_.Load.style(href, media)
Parameters:
href
The URI of the stylesheet to be added to the page
media

default value "screen,projection,tv"

A valid media target. Be warned if you try to use "all" a warning will be issued since you should be saying WHAT your stylesheets are for, not blindly throwing it at everything!!! If you're not down with that, I've got two words for ya...

Returns:
Nothing

Yes, we realize that under the latest HTML 5 rules "projection" and "tv" are no longer valid. To blazes with that noise since there are plenty of devices in circulation that will still override your screen rules with their own or just flat out fail to see them if you omit those properties.

Besides, what values are valid inside the media attribute has NO business being in the HTML specification as that's per-browser instructions. This only creates vendor lock-in by making device makers less likely to want to implement new devices with different capabilites; or worse banging their heads against the walls getting new types approved at the speed of bureaucracy!

Example

JavaScript

_.Load.style('scriptedPrint.css', 'print');

Advertisement