1

Let's say I create an html document in js:

var myHtmlDoc = document.createElement('html');

And then assign it is some html with '@page' defined:

myHtmlDoc.innerHTML = '<html><head><style>@page {size: 320mm 120mm;margin: 10mm;}</style></head><body></body></html>';

Spaced/indented html from above quote for readability:

<html>
    <head>
        <style>
            @page {
               size: 320mm 120mm;
               margin: 10mm;
            }
        </style>
    </head>

    <body>
    </body>
</html>

Let's say I want to get the "size" and "margin" values out of myHtmlDoc (which I won't be defining by hand) and assign them to variables. How would I do that with raw javascript and/or jQuery?


Attempted solutions:

Tried the solution shown in this plunk from the answer here: Find all CSS rules that apply to an element - this causes an error if used with @page:

Uncaught SyntaxError: Failed to execute 'matches' on 'Element': '@page' is not a valid selector.

Will be updating the question with things that work/don't work.

Community
  • 1
  • 1
VSO
  • 11,546
  • 25
  • 99
  • 187
  • 1
    http://stackoverflow.com/questions/754607/can-jquery-get-all-css-styles-associated-with-an-element http://stackoverflow.com/questions/324486/how-do-you-read-css-rule-values-with-javascript http://stackoverflow.com/questions/2952667/find-all-css-rules-that-apply-to-an-element – Sergiu Paraschiv Jan 25 '16 at 21:21
  • Thanks Serg, I am looking through the answers now. My concern is whether @page is supported in the regular manner. – VSO Jan 25 '16 at 21:33
  • That I do not know. Give it a try and let us know too. I don't know of any other way though. – Sergiu Paraschiv Jan 26 '16 at 07:22

0 Answers0