Help Center

Local Navigation

Object: CSSMediaRule

Availability

BlackBerry® Device Software version 4.6 or later

Extends

CSSRule

The CSSMediaRule interface represents an @media rule in a CSS style sheet. The @media rule is used to delimit style rules for specific media types.

CSSMediaRule properties

Property name

Type

Description

Status

Availability

CSSRules

CSSRuleList

Returns a list of the CSS rules contained within a media block.

read only

4.6 or later

media

MediaList

Returns a list of media types that this style sheet can be used with.

read only

4.6 or later

CSSMediaRule methods

Method name

Description

Availability

deleteRule()

Removes a rule from the media block.

4.6 or later

insertRule()

Adds a rule to the media block.

4.6 or later

Method: CSSMediaRule.deleteRule()

Availability

BlackBerry® Device Software version 4.6 or later

The deleteRule() method removes the media block within a CSS style sheet.

Syntax

CSSMediaRule.deleteRule( index )

Parameters

Parameter

Type

Description

index

int

The position of the rule to remove in the media block’s collection of rules.

Return values

None.

Exceptions

Exception

Description

INDEX_SIZE_ERR

This error is thrown if index does not correspond to any rule in the media block’s collection of rules.

NO_MODIFICATION_ALLOWED_ERR

This error is thrown if the media rule is read only.

Method: CSSMediaRule.insertRule()

Availability

BlackBerry® Device Software version 4.6 or later

The insertRule() method adds a rule to the media block.

Syntax

CSSMediaRule.insertRule( rule, index )

Parameters

Parameter

Type

Description

rule

String

The text representing the rule. For rule sets, this contains both the selector and the style declaration. For at rules, this contains both the at-identifier and the rule content.

index

int

The position of the rule in the media block’s collection of rules before which to insert the new rule.

If index is equal to the length of the index, the new rule will be added to the end of the media block.

Return values

Returns the index position of the newly added rule.

Exceptions

Exception

Description

HIERARCHY_REQUEST_ERR

This error is thrown if rule is not permitted at the specified index, for example, if you tried to insert an @import rule after a standard rule set or other at-rule.

INDEX_SIZE_ERR

This error is thrown if index does not correspond to any rule in the media block’s collection of rules.

NO_MODIFICATION_ALLOWED_ERR

This error is thrown if the media rule is read only.

SYNTAX_ERR

The error is thrown if the rule has a syntax error and cannot be parsed.

Previous topic: CSSImportRule properties

Was this information helpful? Send us your comments.