page object

Browser support:
Represents a @page at-rule.
Although the page object is supported, but the @page at-rule does not work in Internet Explorer before version 8.
If you want to add a new @page rule to a style sheet, use the addPageRule method in Internet Explorer.
In Firefox, Opera, Google Chrome, Safari and Internet Explorer from version 9, use the CSSPageRule object instead.


Methods that return the object:
pages.item (index)
The base interface, through which you can add new functionalities to the page object, is the StyleSheetPage interface.

Possible members:

Returns the name of the pseudo class associated with the @page at-rule.
Returns the selector component of a @page rule as a string.

Example HTML code 1:

This example shows how to get a @page at-rule in different browsers:
    <style id="myStyle">
        @page :first {
            margin-left: 13cm;
            margin-right: 4cm;

    <script type="text/javascript">
        function GetPageRule () {
            var styleTag = document.getElementById ("myStyle");

                // the style sheet in the style tag
            var sheet = styleTag.sheet ? styleTag.sheet : styleTag.styleSheet;

            if (sheet.cssRules) { // all browsers, except IE before version 9
                    // the page rules are not in the cssRules collection
                    // in Firefox and Safari before version 5
                if (sheet.cssRules.length > 0) {
                    var pageRule = sheet.cssRules[0];
                    alert (pageRule.cssText);
            else {  // Internet Explorer before version 9
                if (sheet.pages) {
                    var pageRule = sheet.pages[0];
                    alert (pageRule.selector + ":" + pageRule.pseudoClass);

                // Firefox, Safari before version 5
            alert ("Your browser does not support this example!");
    <button onclick="GetPageRule ()">Get the page rule!</button>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content