Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1219 How can I place a watermark background image in the centre of the page?

You are here: irt.org | FAQ | DHTML | Q1219 [ previous next ]

Try:

<html>
<head>
<script language="JavaScript"><!--
function placeWatermark() {
    if (document.layers) {
        document.watermark.pageX = (window.innerWidth -= document.watermark.document.myImage.width)/2;
        document.watermark.pageY = (window.innerHeight -= document.watermark.document.myImage.height)/2;
        document.watermark.visibility = 'visible';
    }
    else if (document.all) {
        document.all.watermark.style.posLeft = (screen.width -= document.myImage.width)/2;
        document.all.watermark.style.posTop = (screen.height -= document.myImage.height)/2 - 50;
        document.all.watermark.style.visibility = 'visible';
    }
}
//--></script>
</head>

<body onLoad="placeWatermark()">

<div id="watermark" style="position: absolute; z-index: -1; visibility: hidden"><img name="myImage" src="watermark.gif" width="200" height="200"></div>

<div style="position: relative;">

place the body of your page within this DIV.

<div>

</body>
</html>

Feedback on 'Q1219 How can I place a watermark background image in the centre of the page?'

©2018 Martin Webb