On some pages I have reason for adding a watermark, but those pages will not always require said watermark. As such I would like to dynamically add a style attribute to the body tag with JavaScript. I've written the below code to add the style attribute to a page's body tag, but I don't get my watermark. If I place the style attribute directly in the body tag I get the appropriate result. What am I missing here?
My body tag looks like this:
My body tag looks like this:
Code:
// initializeScreen() has code to call addReadOnlyWatermark()
<BODY BGCOLOR="cornsilk" onLoad="initializeScreen();">
Code:
function addReadOnlyWatermark()
{
var bodyTag = document.getElementsByTagName("body")[0];
bodyTag.setAttribute("style","background-image:url(../images/readonly.gif);background-attachment:fixed;background-position:100% 100%;background-repeat:no-repeat;");
}