473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

@page and style

To set an item's style properties I can do something like this:

var foo = document.getElementById("bar");
bar.style.width = "100px";

But how do I set the style of paged media i.e. the @page rule?

Specifically I need to set this CSS:

@page {
size: landscape;
margin: 10%;
}

Andrew Poulos
Sep 11 '08 #1
2 1548
Andrew Poulos wrote:
[...] how do I set the style of paged media i.e. the @page rule?

Specifically I need to set this CSS:

@page {
size: landscape;
margin: 10%;
}
var s = document.createElement("style");
if (s)
{
s.type = "text/css";

s.appendChild(
document.createTextNode(
"@page { size: landscape; margin: 10%; }"));

document.getElementsByTagName("head")[0].appendChild(s);
}
HTH

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Sep 12 '08 #2
Thomas 'PointedEars' Lahn wrote:
Andrew Poulos wrote:
>[...] how do I set the style of paged media i.e. the @page rule?

Specifically I need to set this CSS:

@page {
size: landscape;
margin: 10%;
}

var s = document.createElement("style");
if (s)
{
s.type = "text/css";

s.appendChild(
document.createTextNode(
"@page { size: landscape; margin: 10%; }"));

document.getElementsByTagName("head")[0].appendChild(s);
}
Sadly:

IE 7 complains that
Error: Unexpected call to method or property access.
At the "s.appendChilde" line.

FF 3 gives the error:
Unrecognised at-rule or error parsing at-rule '@page'.

Opera 9.5 is happy (no error and the page prints in landscape).

Safari ignores it (no error but the page prints in portrait).

Chrome ignores it (no error but the page prints in portrait).

Looking it a bit more it seems that the @page rule may not be supported.
It was dropped from CSS 2.1 :-(

Andrew Poulos
Sep 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kenneth P | last post by:
Hi, I'm developing asp.net (vb) apps in VS.NET 2003, and I'd like to know how you can write style sheet code in a sub in an .aspx page that when it's rendered as html/text/css code in the .aspx...
0
by: Arora Smith | last post by:
I have datagrid as PagerStyle.Mode = NumericPages. All the page numbers will be displayed with three dots on either side for user to navigate the page. How to change the three dots to choice of my...
7
by: GaryDean | last post by:
In my old 1.1 apps the default was MS_POSITIONING="GridLayout" and Textboxes and labels and such always had POSITION: absolute; and I never had any distortion when the page was rendered. Life was...
8
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB"...
9
by: =?Utf-8?B?Sm9obiBCYWlsZXk=?= | last post by:
I have a ASP .Net page that allows moving around items on the page through javascript. This page works fine in IE. In FireFox however, I have found that if the page is using XHTML 1.0...
3
by: J055 | last post by:
Hi I want to add some css rules to the this.Header.StyleSheet property. I need to add margin and some other css properties but the Style class doesn't support them. What is the best way or some...
2
by: David C | last post by:
I am acclimating to ASP.NET 2.0, so excuse me not using the proper terminology. When I say a content page, I meant, a page that has a MasterPageFile tag in the Page directives. So is that a...
1
by: theoni | last post by:
hello, i have been looking online for an answer to my problems but no luck so far. When I include a page within another page the style does not work. The page I try to include either appears...
2
by: =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?= | last post by:
I have a web page which use a master page. I would like to post a style element to the master page header section how do I do that? -- Arne Garvander Certified Geek Professional Data Dude
4
by: Nathan Sokalski | last post by:
I have a content page from which I need to add a style rule to be used by the page. Since content pages only have the content tags, I obviously need to edit the Master page's style using code. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.