WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Desktop Background, Dave, January 28, 2005
     Re:Desktop Background, Erik Arvidsson, February 8, 2005

Subject: Re:Desktop Background From: Erik Arvidsson Date: February 8, 2005
I usually have the VML clock on my desktop. To make it look neater I set the background for that desktop item to the same as the background of the desktop. It is a hack but it works.

Here is the code that I'm using:

----------- background.js -------------
function setBackgroundImage(oWindow) {
//alert("setBackgroundImage");
var frameWin = oWindow;
var body = frameWin.document.body;
try {
var frameEl = top.frameElement;
var pBody = frameEl.ownerDocument.body;
}
catch (ex) { // not on desktop
return
}

if (pBody.firstChild == null || pBody.firstChild.tagName == "IFRAME" ||
pBody.firstChild.tagName == "OBJECT") {
// TILE
//alert("tile");
body.style.backgroundImage = "url(" + pBody.background + ")";
body.style.backgroundPositionX = - frameWin.screenLeft + "px";
body.style.backgroundPositionY = - frameWin.screenTop + "px";
}
else { // CENTER or STRETCH
//alert("center or stretch");
if (!body.firstChild || !body.firstChild.isBackgroundContainer) {
body.insertAdjacentHTML("afterBegin", pBody.firstChild.outerHTML);
body.firstChild.isBackgroundContainer = true;
}
body.firstChild.style.left = - frameWin.screenLeft + "px";
body.firstChild.style.top = - frameWin.screenTop + "px";
body.firstChild.style.zIndex = -100000;

if (body.firstChild.firstChild) { // stretch image
body.firstChild.firstChild.style.width = screen.width + "px";
body.firstChild.firstChild.style.height = screen.height + "px";
}

body.firstChild.contentEditable = false;
body.firstChild.unselectable = true;
body.ondragstart = function () { return false; };
pBody.firstChild.contentEditable = false;
pBody.firstChild.unselectable = true;
pBody.ondragstart = function () { return false; };
}
}

function removeBackgroundImage(oWindow) {
//alert("removeBackgroundImage");
var body = oWindow.document.body;
body.style.backgroundImage = "";
body.style.backgroundPosition = "";
if (body.firstChild && body.firstChild.isBackgroundContainer)
body.removeChild(body.firstChild);
}

function fixBackgroundImage(oWindow) {
removeBackgroundImage(oWindow);
setBackgroundImage(oWindow);
}
------------ end of file -------------

erik



Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX