Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic DIV background image 1

Status
Not open for further replies.

furan

Programmer
Aug 17, 2001
17
0
0
GB
All,
I've been creating a kind of mouse over tool tip which uses javascript to position a DIV near the mouse and used div.innerHTML to display the appropriate text.
Problem is that I would like to keep the theme of the rest of the site which involves a background image to this (previously static) 'floating' div. The DIV is resized to accomodate the amount of text intended for it, problem is dynamically resizing the background image . . which currently tiles for large amounts of text... anyway, here's the snippet.. any help appreciated.

stuart


function floatDIV(x, y)
{
document.all.display.style.left = x + 75;
document.all.display.style.top = y;
document.all.display.style.visibility ='visible';
}

function ieCoords() {
var xpos = event.clientX;
var ypos = event.clientY;
var width = document.all.display.innerHTML.length*2;
var height = document.all.display.innerHTML.length
//status = "x: "+ xpos +" y: " +ypos;
setDiv(width, height); //another function ...
divBackground = new Image();
divBackground.src = 'images/divbackground1.gif';
divBackground.width = width;
divBackground.height = height;
display.style.backgroundImage='url'+divBackground.src+')';
floatDIV(xpos, ypos);

}


I see why this doesn't work ... I just don't know how else to call the backgroundImage but give it a different size.!
 
furan,

i may be way off here, but i would use 2 layers.
the top layer would have your info in it.

the bottom layer, being exaclty the same size and position as top layer would have a 1row/1col table in it that holds an img set at 100% by 100%.

...just an idea Hope it helps ;)

~ jsLove
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top