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!

Moving DIV with background image

Status
Not open for further replies.

furan

Programmer
Aug 17, 2001
17
0
0
GB
All,
I'm trying to create a DIV which will appear when an onmouseover event is fired and will have a background Image displayed with some text on it. I'm getting some really weird behaviour and not sure how to solve it...
I've simplified the example below ... when it is loaded you will see that onmouseover, the div appears as it should with the image. Taking away the mouse makes it dissappear, as it should. Moving the mouse over again and the DIV appears but with no image?? what is going on?

any help,

Stuart



<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName==&quot;Netscape&quot;)&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function div_background() {
display.style.visibility = 'visible';
display.innerHTML = ('<h1>Hello</h1>');
display.style.backgroundImage = 'url(images/divbackground.gif)';
}

function hide() {
display.style.visibility ='hidden';
}
// -->
</script>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot; >
<div id=&quot;display&quot; onmouseover=&quot;div_background()&quot; onmouseout=&quot;hide()&quot; style=&quot;position:absolute; width:325px; height:203px; z-index:1; left: 296px; top: 221px&quot;></div>
</body>
</html>


 
quick apologies . . I have managed to fix it . . syntax for the image was wrong and in the simplified example i gave it wouldn't work because the DIV was hidden . . no mouserover . .doh!

thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top