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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with DIV

Status
Not open for further replies.

DKL01

Programmer
Sep 14, 2000
233
US
Hi,

I was wondering what's the problem with this code. As long as cursor ir over the text "Move cursor...." the page should display the DIV with message "Sample Text". But with this code it is flickering. Any suggestions ? I'm using IE 5.5

<%@ Language=VBScript %>

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>

<div id=div1> </div>

<script language=&quot;JavaScript&quot;>
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all

var stl,iex=(document.all),yyy=-1000;

stl=document.all.div1.style
Xoffset= -50;
Yoffset= 20;

function get_mouse(e){
var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
stl.left=x+Xoffset;
var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
stl.top=y+yyy;
}

function show() {
var content;
content = &quot;<TABLE BGCOLOR=336699 BORDER=1><TR><TD> Sample Text </TD></TR></TABLE>&quot;
div1.innerHTML = content
stl.display='';
}

function kill() {
stl.display='none';
}
document.onmousemove=get_mouse;
</script>

<a onmouseover=&quot;show()&quot; onmouseout=&quot;kill()&quot; >Move cursor here to popup message </a>

</BODY>
</HTML>


Thanks
 
This is easily solved there is nothing wrong with the code.

What is happening is the div1 is not being included in the document flow at the start as its display property is switched to none. When you make it visible in the document flow by mouseover the link it shifts the link down the pgae as the div is now in its place. This in turn fires the mouseout event for the link hiding the div and shifitng the link back up the page which in turn fires the mouseover event and hence the flickering.

Try shifitng the link to the line above the div in the code and you will find it works fine.

hope this helps

rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top