Forum How do I...?

Setting page background image based upon content.

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?

<style type='text/css'>

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

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

bgimage {string-set: BackgroundUrl content()}

<h1>Hello there</h1>
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.
Thank you @mikeday.