Forum How do I...?

Setting page background image based upon content.

perrys
Using the code below, I'm able to set the content of the page header to the BackgroundUrl string value. However, what I'd really like to do is use the string value to set the background image of the page.

Does anyone know how I can do this?


<html>
<style type='text/css'>

@page {
@top { content: string(BackgroundUrl) }

background-image: url("bg.jpg");
}

bgimage {string-set: BackgroundUrl content()}
</style>
</head>

<body>
<h1>Hello there</h1>
<bgimage>url("bg.jpg")</bgimage>
</body>
</html>
mikeday
Unfortunately string values are always interpreted as if literally quoted; you would need to use JavaScript for this and create a <style> element dynamically with the desired @page rule.
perrys
Thank you @mikeday.